From: Tim Hunter Date: 2007-01-30T03:50:05+09:00 Subject: Re: Object.id problem Tom Pollard wrote: > > On Jan 29, 2007, at 12:28 PM, Alex Amat wrote: >> I have a web service with a method called {}id however when i call this >> method project.id it returns the Object id instead of calling the method >> id. >> >> Any ideas on how to call the method id > > I've run into the same problem. My conclusion is that 'id' is > effectively a reserved method name in Ruby, and you simply need to avoid > creating your own 'id' method. I just don't see how a custom 'id' > method could possibly avoid interfering with Object#id. > > Tom > Use __id__ instead of just id. C:\temp>irb irb(main):001:0> class Foo irb(main):002:1> def id irb(main):003:2> return "HELLO" irb(main):004:2> end irb(main):005:1> end => nil irb(main):006:0> f = Foo.new => # irb(main):007:0> f.id => "HELLO" irb(main):008:0> f.__id__ => 21613128 irb(main):009:0>