Difference in module_eval taking block vs. taking string (1.8 bug?)

J

Jim Cain

The following code:

class Klass
end
p Klass.instance_methods(false)
Klass.module_eval do
def hello
puts 'hello'
end
end
p Klass.instance_methods(false)
Klass.module_eval("def hello2() puts 'hello2'; end")
p Klass.instance_methods(false)

produces this output in 1.8.0pre3:

[]
[]
["hello2"]

but in 1.6.8 it produces:

[]
["hello"]
["hello2", "hello"]

Is this a bug in 1.8 or a feature?
 
Y

Yukihiro Matsumoto

Hi,

In message "Difference in module_eval taking block vs. taking string (1.8 bug?)"

|Is this a bug in 1.8 or a feature?

It was a bug fixed July 2 2003.

Wed Jul 2 13:22:39 2003 Yukihiro Matsumoto <[email protected]>

* eval.c (rb_yield_0): override visibility mode for module_eval
etc. (ruby-bugs-ja PR#505)


matz.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top