Created
October 24, 2011 13:06
-
-
Save hyfather/1308977 to your computer and use it in GitHub Desktop.
Demonstrates how :map can be used on class:Array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[: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