From: Ron Jeffries Date: 2002-03-20T08:41:10+09:00 Subject: Re: style choice On Tue, 19 Mar 2002 14:39:01 GMT, Paul Brannan wrote: >> 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 > >Possibly because this leads to less duplication of code; the code that >returns @degree is found only once here, and twice in the original two >snippets. Yes, I thought of that one as well of course, but didn't do it because (I guess) like like if/end a little less than I like the dual exit. We commonly do that early exit in Smalltalk with a pattern called Guard Clause. Ronald E Jeffries http://www.XProgramming.com http://www.objectmentor.com I'm giving the best advice I have. You get to decide whether it's true for you.