Created
March 14, 2013 11:42
-
-
Save karthikselva/5160723 to your computer and use it in GitHub Desktop.
I feel geekish ( readability is absent for sure ) when I use map with an symbol proc for an array :D
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
| # Convert all elements in an array from integer to string | |
| [1,2,3].map(&:to_s) | |
| # Test output: | |
| # =========== | |
| # | |
| # 1.8.7-p358 :001 > a = [1,2,3] | |
| # | |
| # => [1, 2, 3] | |
| # | |
| # 1.8.7-p358 :002 > a.map(&:to_s) | |
| # | |
| # => ["1", "2", "3"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment