Created
November 21, 2012 03:53
-
-
Save samueljseay/4122912 to your computer and use it in GitHub Desktop.
tutorial error
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
1.9.3p327 :013 > pets = %w(rex nibbles fred) | |
=> ["rex", "nibbles", "fred"] | |
1.9.3p327 :014 > puts pets.map do |pet| | |
1.9.3p327 :015 > pet.upcase | |
1.9.3p327 :016?> end | |
#<Enumerator:0x007f9b4d02a4f0> | |
=> nil | |
1.9.3p327 :017 > puts pets.map(&:upcase) | |
REX | |
NIBBLES | |
FRED | |
=> nil |
you didn't do this:
puts pets.map do |pet|
pet.upcase
end
the 2 are equivalent but result for some reason is different...
@schneems yep, @samueljseay is right.
@schneems on the video I think you didn't want "puts" in there.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1.9.3p194 :002 > %w(foo bar baz)
=> ["foo", "bar", "baz"]
1.9.3p194 :003 > array = %w(foo bar baz)
=> ["foo", "bar", "baz"]
1.9.3p194 :004 > result = array.map do |x|
1.9.3p194 :005 > x.upcase
1.9.3p194 :006?> end
=> ["FOO", "BAR", "BAZ"]
1.9.3p194 :007 >
1.9.3p194 :008 >
1.9.3p194 :009 > puts result.inspect