Created
May 1, 2015 21:43
-
-
Save l3kn/cce27f600faba8f6e887 to your computer and use it in GitHub Desktop.
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
def test1 | |
puts (1..10).to_a.map { |a| a.to_s }.join | |
end | |
def test2 | |
puts((1..10).to_a.map { |a| a.to_s }.join) | |
end | |
def test3 | |
puts (1..10).to_a.map do |a| | |
a.to_s | |
end.join | |
end | |
def test4 | |
puts((1..10).to_a.map do |a| | |
a.to_s | |
end.join) | |
end | |
test1 | |
# => 12345678910 | |
test2 | |
# => 12345678910 | |
test3 | |
# => #<Enumerator:0x000000018fc158> | |
test4 | |
# => block_test.rb:12:in `test3': undefined method `join' for nil:NilClass (NoMethodError) | |
# from block_test.rb:23:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment