Ruby初心者質問スレPart2
■ このスレッドは過去ログ倉庫に格納されています
0040デフォルトの名無しさん
05/02/27 16:11:31失礼しますた。
class Point
attr_reader :x,:y
def initialize(x,y)
@x = x
@y = y
end
def eql? other
self.class == other.class and
@x == other.x and
@y == other.y
end
end
p1 = Point.new(1,1)
p2 = Point.new(2,3)
p1.eql? p2 # 警告
p1.eql?(p2)
■ このスレッドは過去ログ倉庫に格納されています