Skip to content

Instantly share code, notes, and snippets.

@mjhea0
Created April 23, 2013 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjhea0/5444798 to your computer and use it in GitHub Desktop.
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?
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