I'm used to being able to shorten
some_array.map { |e| e.to_s }
to
some_array.map(&:to_s)
Is there a way to shorten
some_array_of_arrays.map { |e| e[4] }
similar to
some_array_of_arrays.map(&:[4])
Obviously I've tried that last example but it doesn't work. Ideally the solution would be generalized to other 'weirdly formatted' method calls like []
.
I am not interested in any Rails/ActiveSupport solution. Plain Ruby only, assuming there is some sort of solution.