From: Mark Hahn Date: 2001-11-30T10:16:06+09:00 Subject: [ruby-talk:27011] Re: Why use symbols (was: Can this be factored?) Thanks. I knew there had to be some other way to use them than just eval. -----Original Message----- From: Matt Armstrong [mailto:matt+dated+1007513886.2f1102@lickey.com] Sent: Thursday, November 29, 2001 4:58 PM To: ruby-talk ML; Mark Hahn Cc: ruby-talk ML Subject: [ruby-talk:27008] Re: Why use symbols (was: Can this be factored?) "Mark Hahn" writes: > I've never processed symbols before. If I have an object and a symbol of an > instance variable, do I have to use eval to access the value, or is there a > faster way? Object#send > def printSide obj, side > puts eval("obj."+side.id2name) > end > printSide(node,:left) Try: def printSide(obj, side) puts obs.send(side) end -- matt