True の ID は 2

LONERさん
LONERさん

ruby で true.id を調べると、2が出てきます。

1.8.7-p374 :001 > true.id
(irb):1: warning: Object#id will be deprecated; use Object#object_id
=> 2
1.8.7-p374 :002 > false.id
(irb):2: warning: Object#id will be deprecated; use Object#object_id
=> 0
1.8.7-p374 :003 > nil.id
(irb):3: warning: Object#id will be deprecated; use Object#object_id
=> 4
1.8.7-p374 :004 > Object.id
(irb):4: warning: Object#id will be deprecated; use Object#object_id
=> -610169198
1.8.7-p374 :007 > Integer.id
(irb):7: warning: Object#id will be deprecated; use Object#object_id
=> -610179398
1.8.7-p374 :012 > Float.id
(irb):12: warning: Object#id will be deprecated; use Object#object_id
=> -610180528

true.object_id, Integer.object_id が正しいメソッド名だそうです。へぇ~。
LONERさんのブログ一覧