From: Michael Glaesemann Date: 2008-07-10T14:26:22+09:00 Subject: Re: Problem with hash in function On Jul 10, 2008, at 12:48 AM, Skave Rat wrote: > Somehow I'm missing something really basic. Why is following function > now working? > > def foobar(args) > puts args.id > end > > foobar ({:id => "MyID"}) > #=> some random number (e.g. -616990888) Are you expecting foobar({:id => "MyID"}) to return "MyID"? args.id will return the object id of args (though this is deprecated. I suspect you want args[:id] instead. >> def foobar(args) >> puts args.id >> end => nil >> foobar ({:id => "MyID"}) (irb):2: warning: Object#id will be deprecated; use Object#object_id 1780410 => nil >> def foobad(args) >> puts args[:id] >> end => nil >> foobad({:id => "MyID"}) MyID => nil Michael Glaesemann grzm seespotcode net