Skip to content

Instantly share code, notes, and snippets.

@l3kn
Created May 1, 2015 21:43
Show Gist options
  • Save l3kn/cce27f600faba8f6e887 to your computer and use it in GitHub Desktop.
Save l3kn/cce27f600faba8f6e887 to your computer and use it in GitHub Desktop.
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