> 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.

I would make a module method like so:

module Oddities
  extend self

  def sum(*args)
    return nil if args.include? nil
    args.sum
  end
end

Oddities.sum nil, 12.0 => nil
Oddities.sum 10, 12.0, 6 => 28.0

Of course you can name your module whatever you want. You can also do it as a mixin:

class MyClass
  include Oddities

  def some_method
    sum(@a, @b)
  end
end


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