From: Terry Poulin Date: 2007-09-27T07:37:21+09:00 Subject: Re: so surprised syntax error not caught here Austin Ziegler wrote: > > It's treating "elif" as a (possible) method call that's never reached > because of the "return". You don't need "return" for what you have: > > def foo(i) > if i < 0 > "Less than 0" > elif i.zero? # i == 0 > "Equal to 0" > else > "Greater than 0" > end > end > > That will fail, but not with a syntax error. (It should fail with an > UnknownMethod.) Ruby is expression-oriented, and the last expression > executed in the execution path is returned from the execution path. > > -austin > -- > Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/ > * austin@halostatue.ca * http://www.halostatue.ca/feed/ > * austin@zieglers.ca > > My word, you have just given me a reason to stop using returns !!! It doesn't hurt code readability to go by syntax rather then insert the "Yes Mr/Miss Programmer don't forget we return here" return statements through out code ether. TerryP. -- Email and shopping with the feelgood factor! 55% of income to good causes. http://www.ippimail.com