I would like to replace this:
[[1,'a'],[2,'b'],[3,'c']].map {|p| p.first}
with a more terse version by sending a reference to Array's first
method to map
, but it gives me errors:
[[1,'a'],[2,'b'],[3,'c']].map Array.method(:first)
I would like to replace this:
[[1,'a'],[2,'b'],[3,'c']].map {|p| p.first}
with a more terse version by sending a reference to Array's first
method to map
, but it gives me errors:
[[1,'a'],[2,'b'],[3,'c']].map Array.method(:first)
Try this:
[[1,'a'],[2,'b'],[3,'c']].map(&:first)