From: Sky Yin Date: 2006-01-23T23:18:48+09:00 Subject: Re: Line breaking in Ruby can be dangerous Thanks. When I first found it out, it's really a *big* surprise. This actually took me quite a while to debug, cause the long expression itself that I wrote simply looked nothing-wrong at the first glance. On 1/23/06, Adriano Ferreira wrote: > On 1/23/06, Florian Frank wrote: > > "1 * 2" and "+ 1" are both valid ruby expressions, the latter "(unary +) > > 1". How should Ruby find out, that you wanted to continue your first > > expression in the next line? > > Ruby would find it out because of the leading "(" or that would be > what I and apparently Sky Yin expect. > > This works: > irb(main):001:0> (1 > irb(main):002:1> ) > => 1 > > This too: > irb(main):003:0> begin (1 > irb(main):004:2> ) end > => 1 > > But I think I understand why it works this way. In Yin's example: > > (1*2 > +1) > > is interpreted just like > (1*2; > +1) > > what would not happen if he had written > (1*2+ > 1) > > which gives a proper answer. > > Kind regards, > Adriano. > > -- Blog >>> http://spaces.msn.com/members/skyincookoo