Skip to content

Instantly share code, notes, and snippets.

@ggarnier
Created August 6, 2015 15:58
Show Gist options
  • Save ggarnier/1b9db2f739ed7b6e7e1e to your computer and use it in GitHub Desktop.
Save ggarnier/1b9db2f739ed7b6e7e1e to your computer and use it in GitHub Desktop.
Ruby block has a different priority when using "do..end" or "{}"
def test1(params)
p "test1 #{params}"
end
def test2(&block)
if block_given?
p "test2 with block"
yield
else
p "test2 without block"
end
"test2"
end
test1 data: test2 do
p "block with 'do..end'"
end
test1 data: test2 {
p "block with '{}'"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment