From: Eli Bendersky Date: 2006-05-13T00:09:59+09:00 Subject: Making sense of the various Ruby "eval"s Hi all, Unlike other dynamic languages I'm familiar with (Perl, Lisp), Ruby has more than one form of 'eval', which is quite confusing for Ruby nubies like myself. I'm trying to make some sense of all the possibilities: - Kernel#eval - This one I (almost) understand. It behaves like Perl's eval, with the difference that it can take a 'binding' which is another Object, or Proc. In case of the Object I understand that the code 'eval'ed can access the Object's instance vars. But how does that work with a Proc as a binding ? - Object#instance_eval - Is obj.instance_eval("blah") exactly the same as eval("blah", obj) ? If the answer to this question is positive, then the string version of instance_eval is clear. But what about its block version ? How does that work ? Are the contents of the block just treated as a string ? - Module#class_eval - With its synonym module_eval: very similar to Object#instance_eval, just that all methods are added to a class and not to an object, right ? Thanks in advance -- Posted via http://www.ruby-forum.com/.