Skip to content

Instantly share code, notes, and snippets.

@jobwat
Created May 2, 2014 07:03
Show Gist options
  • Save jobwat/ca9cc1ca2d097869f9f8 to your computer and use it in GitHub Desktop.
Save jobwat/ca9cc1ca2d097869f9f8 to your computer and use it in GitHub Desktop.
Constant lookup limitation in Ruby
class Foo
def self.showConstant
puts CONSTANT
end
end
class SubFoo < Foo
CONSTANT='SubFoo string'
end
SubFoo.showConstant
⚡ ruby CONSTANT.rb
CONSTANT.rb:3:in `showConstant': uninitialized constant Foo::CONSTANT (NameError)
from CONSTANT.rb:10:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment