Array.map shortcut

Public, Ruby General

harrylevine

Created: May 24, 2015     Updated: May 24, 2015


In Ruby code, you quite often see the trick of using an expression like:
array.map(&:method_name) as a shorthand form of
array.map { |element| element.method_name }

From: http://www.toptal.com/ruby/interview-questions