Robert Klemme
12/5/2006 10:29:00 AM
On 05.12.2006 10:03, Yukihiro Matsumoto wrote:
> In message "Re: Question about Ruby philosophy"
> on Tue, 5 Dec 2006 17:20:10 +0900, Robert Klemme <shortcutter@googlemail.com> writes:
>
> |I believe I remember that "1 / 2" used to return "Rational(1, 2)" with
> |'rational' loaded. Is my memory wrong here?
>
> Perhaps, you've confused 'rational' and 'mathn'.
Exactly!
>> 1 / 2
=> 0
>> require 'mathn'
=> true
>> 1 / 2
=> 1/2
>> (1 / 2).class
=> Rational
I just notice a strange inconsistency:
>> 12:25:18 [~]: irbs
>> require 'rational'
=> true
>> 1.to_r / 2
=> Rational(1, 2)
>> require 'mathn'
=> true
>> 1 / 2
=> 1/2
>> 1.to_r / 2
=> 1/2
The output of Rational's inspect method seems to change depending on
whether "rational" or "mathn" is required.
Thank you, Matz!
robert