From: Matt Armstrong Date: 2002-03-20T01:28:32+09:00 Subject: Re: style choice Ron Jeffries writes: > A style question for the community ... which of the following do you > prefer, and why? Or, if you prefer some third version, what is it > and why? > > def degree > return @degree if @degree > 0 > @scopes.each { | field | @degree += field.length } > @degree > end > > def degree > @scopes.each { | field | @degree += field.length } if @degree == 0 > @degree > end The two aren't equivalent when @degree is negative. That might determine which one you choose. But still, I'd write it as: def degree unless @degree > 0 @scopes.each { | field | @degree += field.length } end @degree end This and similar forms already posted are the only ones I can read and immediately get the meaning. -- matt