[前][次][番号順一覧][スレッド一覧][生データ]

yarv-dev:1072

From: "Ken Date" <itacchi gmail.com>
Date: Sat, 29 Jul 2006 11:14:24 +0900
Subject: [yarv-dev:1072] open>Float#==(other) don't call other.==

伊達です。

Float オブジェクトと他のオブジェクトを比較したときの振る舞いが、1.8/1.9 とは異なります。
1.8/1.9 では Float#==(other) で other.== が呼ばれているようです。
coerce 絡みの挙動なのでしょうか。

$ ruby-yarv -v -e '
class Foo
  def ==(other)
    true
  end
end
f = Foo.new
p 1.0 == f
p f == 1.0
p 1 == f
p f == 1
'
ruby 2.0.0 (Base: Ruby 1.9.0 2006-04-08) [i686-linux]
YARVCore 0.4.1 Rev: 527 (2006-07-19) [opts: [direct threaded code]
[inline method cache] ]
false
true
true
true

$ ruby18 -v -e '
class Foo
  def ==(other)
    true
  end
end
f = Foo.new
p 1.0 == f
p f == 1.0
p 1 == f
p f == 1
'
ruby 1.8.4 (2005-12-24) [i686-linux]
true
true
true
true

$ ruby19 -v -e '
class Foo
  def ==(other)
    true
  end
end
f = Foo.new
p 1.0 == f
p f == 1.0
p 1 == f
p f == 1
'
ruby 1.9.0 (2006-07-21) [i686-linux]
true
true
true
true

--
ML: yarv-dev quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧][生データ]

->    1072 2006-07-29 11:14 [itacchi gmail.com   ] open>Float#==(other) don't call other.==
      1080 2006-08-17 11:35 ┗[ko1 atdot.net       ] fixed> Re: open>Float#==(other) don't call other.==