From: Steve Litt Date: 2005-12-09T11:22:42+09:00 Subject: Re: do/end vs braces On Thursday 08 December 2005 08:42 pm, Paul Sanchez wrote: > In article <200512082012.03896.slitt@earthlink.net>, > > Steve Litt wrote: > > On Thursday 08 December 2005 06:06 pm, Jacob Fugal wrote: > > > On 12/8/05, Steve Litt wrote: > > > > Except I can't put in the parentheses: > > > > > > > > #!/usr/bin/ruby > > > > my_array = ["alpha", "beta", "gamma"] > > > > puts (my_array.collect do > > > > > > > > |word| > > > > > > > > word.capitalize > > > > end) > > > > > > > > Output: > > > > [slitt@mydesk slitt]$ ./test.rb > > > > ./test.rb:3: syntax error > > > > ./test.rb:6: syntax error > > > > > > Take out the space between puts and the open paren: > > > > Confirmed! Thanks Jacob. This is the first time I've seen Ruby conflict > > with the Rule of Least Surprise > > (http://www.faqs.org/docs/artu/ch11s01.html). > > > > Is there any chance of a Ruby change so as not to require the paren to be > > flush up against the function name? > > Interestingly, it worked for me with a space or without the parens when > I did the puts as a one-liner: > > puts my_array.collect {|word| word.capitalize} > > or > > puts (my_array.collect {|word| word.capitalize}) Hi Paul, It works as expected with braces, but not with do/end. Thanks SteveT Steve Litt http://www.troubleshooters.com slitt@troubleshooters.com