Skip to content

Instantly share code, notes, and snippets.

@mikelikesbikes
Last active August 29, 2015 13:56
Show Gist options
  • Save mikelikesbikes/8809504 to your computer and use it in GitHub Desktop.
Save mikelikesbikes/8809504 to your computer and use it in GitHub Desktop.
What'chu doin' Ruby?
$ ruby -e "a = (0..5).to_a; c = a.map do |x| x*2; end; p c.class"
Array
$ ruby -e "a = (0..5).to_a; c = a.map { |x| x*2; }; p c.class"
Array
$ ruby -e "a = (0..5).to_a; p a.map do |x| x*2; end"
#<Enumerator: [0, 1, 2, 3, 4, 5]:map>
$ ruby -e "a = (0..5).to_a; p a.map { |x| x*2; }"
[0, 2, 4, 6, 8, 10]
@mikelikesbikes
Copy link
Author

@JoshCheek THANKS!

@ryanbriones see Josh's example... it's being interpreted like this:
$ ruby -e "a = (0..5).to_a; p(a.map) do |x| x*2; end"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment