I'm very used to using the ruby &
shorthand for array methods, ex:
a = [1, 3, 4]
a.map(&:to_f)
# => [1.0, 3.0, 4.0]
instead of
a.map {|x| x.to_f }
Is there an equivalent for an array of hashes? For ex:
a = [{'first' => 1, 'second' => 4}, {'first' => 5, 'second' => 6}]
a.map(&:'first')
# => [1, 5]
Something like this? That is a shorthand over a.map { |x| x['first'] }
?
This would be especially useful when I have large arrays of many nested hashes to drill down into.