From: David Alan Black Date: 2002-03-19T22:53:00+09:00 Subject: Re: style choice Hello -- On Tue, 19 Mar 2002, Ron Jeffries wrote: > 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 Interesting -- I'm not as anti-if-modifier as some, but here, maybe because of the length of the pre-if part, I like the first one better. My instincts, such as they are, might lead me to do: def degree if @degree == 0 @scopes.each {|field| @degree += field.length} end @degree end I'm a bit stuck on the "why" part :-) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav