From: Trans Date: 2005-09-23T03:36:39+09:00 Subject: Re: Instantiating a subclass of NilClass. Logan Capaldo wrote: > On Sep 22, 2005, at 1:01 PM, Trans wrote: > > >> Why do you need the boolean behavior? > >> > > > > In particular, I use the boolean behavior to redefine an element of > > the > > OpenStruct-like object under certain circumstances. > > > > unless o.m # could be null > > o.m = foo > > > > Right now I'm using 'if o.m.nil?' but it's not nice. It means one must > > be aware of ths possibiliy of a null rather than nil. And what if > > false > > plays a role? I don't want the end user to have to worry about it. It > > should be just like nil except not error when method missing. > > > > T. > > > > > > > > Whats the problem with just doing > > def nil.method_missing(*args) > self > end > > I think this might be an issue of having your cake and eating it too. I eat lots of cake ;) That can be done, but WATCH OUT! Other programs might depend on the current behavior. And at the very least we frequently depend on nil choking on #[] and other methods to tell us we have a bug in out program. So I think its too risky. But correct me if I've over stated the issue. Thanks, T.