On Wed, 29 Mar 2006, Robert Klemme wrote:

> You could as well leave the member nil and change the getter appropriately:
>
> class Foo
>  def mine() @mine || FROZEN_EMPTY_HASH end
>  def step2() mine.each_pair ...
> end
>
> Or do the test in step2...
> @mine and @mine.each_pair ...

I didn't want to do that since @mine.each and .has_key? was going to be 
evaluated often and in many places.
ie. The optimization tweak would have been a shot gun 
hack all over the place.

However, if anybody had listened to me about the Null Object pattern and 
nil....

I wouldn't have had to do anything.


John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : john.carter / tait.co.nz
New Zealand

Carter's Clarification of Murphy's Law.

"Things only ever go right so that they may go more spectacularly wrong later."

From this principle, all of life and physics may be deduced.