I feel we are making things too complicated because solutions do not
integrate with Ruby's math well. I think OP should override
NilClass#coerce to proper integrate with Ruby's math handling. Then
implement +, -, * and / for NilClass.

class NilClass
  def coerce; [nil, nil] end

  def +(x) nil end
  def -(x) nil end
  def *(x) nil end
  def /(x) nil end
  def %(x) nil end
  def divmod(x) [nil,nil] end
end

Cheers

robert

PS: unfortunately the blog post I did years ago about extending Ruby's
math with new classes is no longer online. I'll try to dig it up and
make it accessible somewhere else.

-- 
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can
- without end}
http://blog.rubybestpractices.com/

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