Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: How to run variable method names?
Phillip Hutchings
7/24/2006 12:51:00 AM
On 7/24/06, Ben Johnson <bjohnson@contuitive.com> wrote:
> Lets say object has a method called id.
>
> How do I do the the following?
>
> method_name = "id"
> object.method_name
>
> I know the above doesnt work, but I want method_name to be replaced
> by its value so it would run id.
In this case Ruby is interpreting method_name as the method to call.
Check out Object#send
object.send(method_name.to_sym)
--
Phillip Hutchings
http://www.sit...
1 Answer
dblack
7/24/2006 1:01:00 AM
0
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: How to run variable method names?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password