Kevin Olemoh wrote:
> Hello I have been using ruby off and on for a few months and I have been 
> having a great time with the language but a few things bother me about 
> the syntax of the language itself.  The two glaring issues are:
> 
> 1. The syntax errors generated by the following code:
> 
> a.each
> do
> #stuff
> end
> 
> for reasons I do not understand ruby demands that, that line be written as:
> a.each do
> #stuff
> end

In ruby statements are terminated by newlines and block is a parameter 
to the each method here, consider:

def meth *args
end

meth
1,2

what is Ruby supposed to do in such situation ? In your case you are 
calling the each method without any argument and supplying another 
statement:

do
end

which obviously is wrong

On the other hand Ruby allows breaking statements when situation is more 
obvious:

def meth *args

end

meth 1,
2


> 
> Quite frankly I find the second form to be more difficult to read 
> especially if one tends to create blocks with braces rather than the do 
> end keywords like I do.  Is there some specific reason that both forms 
> are not supported by Ruby?  It is needlessly restrictive with respect to 
> formatting in my opinion, perhaps a kind ruby-core developer could sneak 
> this syntax change into a future release?
> 

Nope, they are not equivalent. The {} form binds tighter than do end.

def meth,arg
    yield
end

and:

meth a do

end

block applied to the meth method


meth a {

}

block applied do a (which could be a method call) and the result of a 
block would be passed to the meth method


lopex