Quoth mark@mark.mielke.cc (Mark Mielke): > > Another common bit of code that I've written is: > > sub foo > { > my($this) = @_; > exists($this->{'foo'}) ? $this->{'foo'} : do { > ... expensive calculations ... > $this->{'foo'} = ...; > }; > } > > This introduces the other statement that is frequently used to return > the last value without a return - do{}. The above code is not > significantly improved by adding return anywhere. I disagree. IMHO sub foo { my ($this) = @_; exists $this->{foo} and return $this->{foo}; ...expensive calculations... return $this->{foo} = ...; } is clearer in at least two important ways. Ben -- We do not stop playing because we grow old; we grow old because we stop playing. ben@morrow.me.ukThread Previous | Thread Next