Skip to content

Latest commit

 

History

History
15 lines (12 loc) · 287 Bytes

passing-arbitrary-methods-as-blocks.md

File metadata and controls

15 lines (12 loc) · 287 Bytes

Passing Arbitrary Methods As Blocks

Use Object#method to create a callable Method object that can be passed to methods that yield to a block.

def inc(x)
  x + 1
end

[1,2,3].map(&method(:inc))
#=> [2,3,4]