< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事
N :次の記事
|<:スレッドの先頭
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
山本です。
>eql?の再定義がうまくいっていないのでしょうか?
eql? を再定義した場合は、hash も再定義する必要があります。
http://www.ruby-lang.org/ja/man/index.cgi?cmd=view;name=Object#eql.3f
というわけで、こんな感じでしょうか。
class Hoge
def initialize( n )
@name = n
end
def eql?( otr )
@name.eql?( otr.name )
end
def hash # a.eql?(b) が成り立つときは a.hash == b.hash でないといけない
@name.hash # なので、 @name.hash + 1039 なんてものでも OK ?
end
attr_accessor :name
end
dat = [ Hoge.new( "hoge" ),
Hoge.new( "hage" ),
Hoge.new( "boke" ),
Hoge.new( "hage" ),
Hoge.new( "boke" ) ]
dat.uniq!
dat.each do |d|
print d.name,"\n"
end