7stud2
(7stud --)
1 November 2012 17:57
1
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?
···
--
Posted via http://www.ruby-forum.com/ .
11142
(-- --)
1 November 2012 18:56
2
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
···
2012/11/1 Mean L. <lists@ruby-forum.com>:
foo proc do
end, proc do
end
7stud2
(7stud --)
3 November 2012 20:18
3
thanks, good to know about different binding precedence of do end and {}
···
--
Posted via http://www.ruby-forum.com/ .