From: Paul Lutus Date: 2006-12-02T04:50:13+09:00 Subject: Re: Simple iteration in a function problem Blake Miller wrote: > >> >> # pick one by id >> pick = ids[3] >> p pick >> p holder[pick] >> >> # >> #, #, #> 0x1e284c>, >> # >> #, #, #> 0x1e27d4>, >> # >> #, #, #> 0x1e275c>, >> # >> #]> >> # >> 988178 >> # >> # >> >> __END__ >> >> Hope that helps. >> >> James Edward Gray II > > Note: The ids are strings. The @ys.find { |y| y.object_id == id } still > isn't working for me, i also tried y.object_id.equals(id) but I can't > seem to find the darn match : / Please show us your code, and make it as simple as possible. Like this: -------------------------------------- #!/usr/bin/ruby -w b = "b" b_id = b.object_id ys = [ "a",b,"c","d" ] puts ys.find { |i| i.object_id == b_id } # => "b" puts ys.find { |i| i.object_id == b } # => nil puts ys.find { |i| i.object_id == "b" } # => nil -------------------------------------- Notice in your version of the code that "id" must equal the object id, not the object. -- Paul Lutus http://www.arachnoid.com