>>>>> "R" == Raj Singh <neeraj.jsr / gmail.com> writes:

R> Could you please further elaborate on that. To me it  seems like both of 
R> them have the same scope because they are both being used in the same 
R> method.

 Well, when you write this

   y = " another hi"
   
   class Wes
   end
   
   Wes.class_eval <<-END
    def hello
       puts "#{y}"
       puts y # I get wrong number of arguments error
    end
   END


  1) ruby create the string at toplevel (where is defined `y') and this give

    def hello
       puts " another hi"
       puts y # I get wrong number of arguments error
    end

  2) the string is given to class_eval, which create the method #hello
     in Wes

    def hello
       puts " another hi"
       puts y # I get wrong number of arguments error
    end


  when the method is compiled, `y' is resolved as a call to a method (no
  local variable `y' was defined in the def #hello)

  When you call Wes.new.hello, ruby try to call this method and it give you
  an error.



Guy Decoux