Afficher un message
Vieux 15/09/2007, 23h55   #4
Summercool
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: one line to print the statement AS WELL AS the evaluated value like in C


On Sep 15, 5:22 am, Morton Goldberg <m_goldb...@ameritech.net> wrote:
> That didn't work for me. I had modify it like so:
>
> foo = [1, 2, 3, 4, 5]
> def print_val(str)
> puts "#{str} is #{eval(str, TOPLEVEL_BINDING)}"
> end
> print_val("foo[3] + 1")



it works but then if print_val is called inside an instance method,
then it won't work.



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