Skip to content

Instantly share code, notes, and snippets.

@jpr5
Created January 17, 2011 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpr5/783465 to your computer and use it in GitHub Desktop.
Save jpr5/783465 to your computer and use it in GitHub Desktop.
[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