From: merch-redmine@... Date: 2019-07-25T15:29:32+00:00 Subject: [ruby-core:93911] [Ruby master Bug#12485] Kernel.Rational raises TypeError though given denominator returns 1 by to_int Issue #12485 has been updated by jeremyevans0 (Jeremy Evans). File rational-denom-to_int.patch added I'm not sure if this is considered a bug or not. Rational will already try to convert numerator and denominator via `to_r`. However, if we do want to convert via `to_int` if `to_r` is not defined, the attached patch should implement it. ---------------------------------------- Bug #12485: Kernel.Rational raises TypeError though given denominator returns 1 by to_int https://bugs.ruby-lang.org/issues/12485#change-80002 * Author: mrkn (Kenta Murata) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- Is it an intentional behavior? ```ruby class << (o = Object.new) def to_int 1 end end Rational(1, o) #=> TypeError: not an integer ``` ---Files-------------------------------- rational.c.diff (539 Bytes) rational-denom-to_int.patch (1.73 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: