OK, real quick, here's the code:
class A
def foo
FOO
end
def self.foo
FOO
end
end
module B
class C < A
end
end
B.const_set(:FOO,'asdf')
>> B::C.foo
NameError: uninitialized constant A::FOO
from ./foo.rb:6:in `foo'
from (irb):1
>> B.module_eval {FOO='asdf'}
=> "asdf"
>> B::C.foo
=> "asdf"
Aren't they supposed to do the same thing? Why is this happening? At this point, I'm using the module_eval in my code out of necessity, but the const_set seems more readable. Regardless, I'd really like to understand why this happens.