From: John Turner Date: 2006-10-27T15:00:12+09:00 Subject: Re: simple math question M. Edward (Ed) Borasky wrote: > Robert Oliver wrote: >> On 10/26/06, Wilson Bilkovich wrote: >>> class Fixnum >>> def even? >>> (self % 2).zero? >>> end >>> def odd? >>> !even? >>> end >>> end >>> >>> >> I normally do that, but I remember somewhere reading that it was bad >> form to >> not include the return statement. I'm not sure where this was. Is anyone >> familiar with this syntax quasi-rule? >> > I tend to use un-necessary "return" statements in most of my code, > because it makes it easier for me to read. But I suppose the language > designers that provide simplified syntax do so for a reason, so I would > say the correct style is the minimum amount of code the language allows. > Not including a "return" statement makes it all a bit more "functional" in my view. Basically, I'll leave off the return if the method is really simple and it's obvious what the last statement is and that it's being returned. If there's any complex control flow going on then it's nicer to give the "reader"(potentially just yourself, but being nice to your future self is good) the visual clue as to what's actually being returned, even if it's still the last statement executed.