On Aug 14, 2011, at 10:31 AM, Iki Baz Castillo wrote:
> So, if a contstant appears within a method, its value is evaluated for
> the class in which such method is defined ("hello" is defined in class
> A not in B, so it takes HELLO from class A).
> I don't like this behavior (just my opinion). Do I miss something?


class A
  class << self
    attr_accessor :hello
  end
  @hello = "Hello I'm A"

  def hello
    puts self.class.hello
  end
end

class B < A
  @hello = "Hello I'm B"

  def hello2
    puts self.class.hello
  end
end

B.new.hello
#=> "Hello I'm B"

B.new.hello2