[Ruby] eval question

Aaron Patterson aaron at tenderlovemaking.com
Mon Apr 30 13:09:37 PDT 2007


My brain may be dead today, so hopefully the community can help.  :-(

In this code, 'easy_lover' is defined, but for some reason
'phil_collins' is not.  First, why is that?  Second, can I make it so?
You can have Easy Lover without Phil!

  eval(<<END
    phil_collins = 'awesome'
    def easy_lover
      "She'll get a hold on you believe it"
    end
  END
  )
  
  puts easy_lover
  puts phil_collins # Error!

-- 
Aaron Patterson
http://tenderlovemaking.com/


More information about the Ruby mailing list