Last active
August 29, 2015 13:56
-
-
Save mikelikesbikes/8809504 to your computer and use it in GitHub Desktop.
What'chu doin' Ruby?
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
$ 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] |
@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
https://github.com/JoshCheek/ruby-kickstart/blob/39e85fe5e5161c3846fbf40077d8cba53f9080fb/session3/notes/13-difference-between-block-syntaxes.rb