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

Discussion in 'Ruby' started by Jim Cain, Jul 18, 2003.

  1. Jim Cain

    Jim Cain Guest

    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?
    Jim Cain, Jul 18, 2003
    #1
    1. Advertising

  2. Hi,

    In message "Difference in module_eval taking block vs. taking string (1.8 bug?)"
    on 03/07/18, Jim Cain <> writes:

    |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 <>

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


    matz.
    Yukihiro Matsumoto, Jul 18, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. morrell
    Replies:
    1
    Views:
    949
    roy axenov
    Oct 10, 2006
  2. Simon Strandgaard

    overload method in module_eval, how?

    Simon Strandgaard, Nov 10, 2003, in forum: Ruby
    Replies:
    12
    Views:
    224
    Simon Strandgaard
    Nov 10, 2003
  3. Florian G. Pflug

    module_eval, scope, __FILE__ and __LINE__

    Florian G. Pflug, Feb 17, 2004, in forum: Ruby
    Replies:
    0
    Views:
    128
    Florian G. Pflug
    Feb 17, 2004
  4. Brian Mitchell

    Module.nesting and module_eval

    Brian Mitchell, Apr 1, 2005, in forum: Ruby
    Replies:
    1
    Views:
    134
    Yukihiro Matsumoto
    Apr 2, 2005
  5. Kyung won Cheon
    Replies:
    1
    Views:
    91
    Peña, Botp
    Aug 1, 2008
Loading...

Share This Page