From: Mark Sparshatt Date: 2004-06-14T05:55:52+09:00 Subject: Re: Use a string a object name Dirk Einecke wrote: > Mark Sparshatt wrote: > >> puts eval "p.#{s}" > > > Okay. That works. > >> Though depending on what you're doing a better way might be to use >> the send method >> >> puts p.send(s) > > > Why is this a better way? > It's quicker since Ruby doesn't need to parse the expression string. Also, IMHO, it better expresses the fact that you're sending the message contained in s to the object p. -- Mark Sparshatt