How to use a normal Ruby method like a block
foo_plus = "foo".method(:+)
foo_plus.class # Method < Object
foo_plus.arity # 1
foo_plus.call(" bar") # "foo bar"
Credits: http://makandracards.com/makandra/1659-use-a-ruby-method-like-a-block-or-lambda
Written by Matt Campbell
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#