This fails:
foo proc do
end, proc do
end
this works:
foo(proc do
end, proc do
end)
that it doesn't work without parens suggests that there may be
ambiguity, but I don't think there is, the second proc can not be an arg
to the first since it follows the block of the first, also this works
without parens:
foo proc {
}, proc {
}
why is there a difference?
Is there a bug here? If not, what's the reason?
on 2012-11-01 18:57
on 2012-11-01 19:57
2012/11/1 Mean L. <lists@ruby-forum.com>: > foo proc do > > end, proc do > > end foo proc do end is being interpreted as foo(proc) do end, so you get a syntax error on the comma. The curly { } block have higher priority when parsing, so foo proc { } is interpreted as foo(proc { }) and the entire thing works. -- Matma Rex
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.