>>>>
I have the need for things like nil + 12.0 to return nil in the way that some software packages propagate NaN and other oddities.

[กฤ]

Basically I want to patch some classes, like Float and NilClass, run some code and then revert the patches in the middle of some code.
<<<<

There is no easy way to do this*, and I think most Ruby people would say that it was inadvisable. You will be fighting the language all the way if you try it.

I generally try to avoid propagating nil all through my code precisely because of the problems it causes.  Really you are better off catching that nil value and dealing with it in one place, rather than having to deal with it in all the places it could later turn up.

Here's a weird idea: if you really have a need for this, why not make your own nil class specifically for values that need this functionality?  That way you wouldn't have to worry about the rest of ruby being effected by your monkey patching?

[ *_possibly_ refinements might work for you, but I have yet to make them work for me. ]


Click here to view Company Information and Confidentiality Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>

Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>