From: Daniel Kelley Date: 2002-03-20T00:00:01+09:00 Subject: Re: style choice >>>>> "David" == David Alan Black writes: David> Hello -- David> On Tue, 19 Mar 2002, Ron Jeffries wrote: >> >> 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 David> Interesting -- I'm not as anti-if-modifier as some, but David> here, maybe because of the length of the pre-if part, I David> like the first one better. David> My instincts, such as they are, might lead me to do: David> def degree David> if @degree == 0 David> @scopes.each {|field| @degree += field.length} David> end David> @degree David> end I have to say I prefer David's style to the first two because I understood it faster - but maybe that's because I am probably more anti-if-modifier than David is. David> I'm a bit stuck on the "why" part :-) Faster comprehension - for me, at least. d.k. -- Daniel Kelley - San Jose, CA For email, replace the first dot in the domain with an at.