Skip to content

Instantly share code, notes, and snippets.

@hyfather
Created October 24, 2011 13:06
Show Gist options
  • Save hyfather/1308977 to your computer and use it in GitHub Desktop.
Save hyfather/1308977 to your computer and use it in GitHub Desktop.
Demonstrates how :map can be used on class:Array
[:a, :b, :c].map {|e| e.to_s }
#=> ['a', 'b', 'c'] # Invoke .to_s on each element and collect these in an array.
[:a, :b, :c].map(&:to_s)
#=> ['a', 'b', 'c'] # The same result obtained in a shorthand fashion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment