Afficher un message
Vieux 24/02/2008, 02h35   #3
Sam Larbi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Using a variable as a method name?

[Note: parts of this message were removed to make it a legal post.]

On Sat, Feb 23, 2008 at 7:18 PM, Phy Prabab <phyprabab@yahoo.com> wrote:

> This causes Ruby to spit out that there is no method
> called arg which is correct. So how do I get arg to
> be substituted to the value rather than the var name?
> I tried dereferencing and using the it within a string
> (okay, a dumb idea). Any way, any will be much
> appreciated!
>



What is the /type/ of arg?

If it's a Proc, you might try arg.call().

If you're trying to do it via string, look into eval.

Jay Fields has some thoughts:
http://blog.jayfields.com/2006/07/ru...h-binding.html
http://blog.jayfields.com/2006/07/ruby-block-scope.html

I seem to remember seeing a better reference, only I can't recall by whom or
where.

Regards,
Sam

  Réponse avec citation
 
Page generated in 0,04572 seconds with 9 queries