Created
April 23, 2013 15:51
-
-
Save mjhea0/5444798 to your computer and use it in GitHub Desktop.
map and collect do the exact same thing - why? why don't they deprecate one of them? why do i see map used more?
This file contains 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
numbers = (1..10) | |
array1 = numbers.to_a | |
array2 = numbers.to_a | |
# map | |
strings_map = array1.map(&:to_s) | |
# collect | |
strings_collect = array2.collect(&:to_s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment