Ruby Local Method map Shortcut

1 · Seth Vargo · Dec. 29, 2012, midnight
In Ruby, we can pass blocks as directly as variables using &. This allows us to transform really simple map operations like this: arr.map{ |a| a.downcase } into this: arr.map(&:downcase) To me, the latter example is much cleaner, but there are some limitations: You can only call methods which the contained elements respond to. You can't call a local method in your class. This makes it difficult to leverage your own functions without monkey-patching core libraries. For example, say you have a...