Project

General

Profile

Actions

Bug #12485

closed

Kernel.Rational raises TypeError though given denominator returns 1 by to_int

Added by mrkn (Kenta Murata) over 8 years ago. Updated about 4 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
[ruby-core:75995]

Description

Is it an intentional behavior?

class << (o = Object.new)
  def to_int
    1
  end
end

Rational(1, o)  #=> TypeError: not an integer

Files

rational.c.diff (539 Bytes) rational.c.diff mrkn (Kenta Murata), 06/13/2016 02:53 PM
rational-denom-to_int.patch (1.73 KB) rational-denom-to_int.patch jeremyevans0 (Jeremy Evans), 07/25/2019 03:28 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0