[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.toi}
```
Written by Tony612
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Related Tags
#ruby
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#