From: David Alan Black Date: 2001-08-31T21:14:43+09:00 Subject: [ruby-talk:20617] Re: Weird things with eval Hello -- On Fri, 31 Aug 2001, ts wrote: > > >>>>> "D" == David Alan Black writes: > > Well, you don't give the same example I wasn't trying to :-) > D> class Foo; end > D> Foo.class_eval "def bar; puts 'bar'; end" > D> Foo.new.bar # => bar > > here you've used class_eval > > D> class Foo; end > D> Foo.send(:eval, "def thing; end") > D> [].thing > D> -:3: private method `thing' called for []:Array (NoMethodError) > > here you've used eval Right. In the sentence just before these examples, I said: > D> For one thing, keep in mind that Class.send(:eval, str) is not the > D> same as Class.class_eval str. I thought that perhaps Paul had been thinking of these two things as equivalent, so I wanted to demonstrate that they weren't. So I wrote one example of each. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav