Kurt Stephens

Nerd Up!

$ irb irb(main):001:0>


  $ irb 
  irb(main):001:0> require “ks_rational.rb”
  => true
  irb(main):002:0> r = Rational.new! 0, 0
  => Rational0, 0
  irb(main):003:0> r.zero?
  => true
  irb(main):004:0> r = Rational(0, 0)
  ZeroDivisionError: denominator is zero
      from ks_rational.rb:76:in `reduce’
      from ks_rational.rb:39:in `Rational’
      from (irb):2

I’d suggest a warning in the RDoc for #zero? similar to the one for #==. Rational.new! is voodoo! I’d almost recommend it should be Rational.faux!

Reply

Please solve the math problem above and type in the result. e.g. for 1+1, type 2
The content of this field is kept private and will not be shown publicly.

Primary links

Syndicate

Syndicate content

Browse archives

« May 2012  
Mo Tu We Th Fr Sa Su
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31