Skip to content

Instantly share code, notes, and snippets.

@jpr5
Created Jan 17, 2011
Embed
What would you like to do?
[ruby 1.8.7] nested namespaces need physical nesting for const_missing? to work
#!/usr/bin/ruby
class Balls
BALLS = 1
end
class Balls::Dongs
def doit
puts "balls = #{BALLS}"
end
end
Balls::Dongs.new.doit
__END__
$ ruby test.rb
/tmp/test.rb:9:in `doit': uninitialized constant Balls::Dongs::BALLS (NameError)
from /tmp/test.rb:13
$
#!/usr/bin/ruby
class Balls
BALLS = 1
end
class Balls
class Dongs
def doit
puts "balls = #{BALLS}"
end
end
end
Balls::Dongs.new.doit
__END__
$ ruby test.rb
balls = 1
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment