Last Updated: February 25, 2016
·
2.262K
· tony612

[foo1, foo2...].map(&:to_i).map(&:pred)

When you say names.map(&xxx), you’re telling Ruby to pass the Proc object in xxx to map as a block.

If xxx isn’t already a Proc object, Ruby tries to coerce it into one by sending it a to_proc message.
--Dave Thomas

def to_proc
  proc { |obj, *args| obj.send(self, *args) }
end

So, [foo1, foo2...].map(&:toi) can be looked as :
```
[foo1, foo2...].map {|bar| bar.to
i}
```