Skip to content

Instantly share code, notes, and snippets.

@dzhulk
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save dzhulk/11484321 to your computer and use it in GitHub Desktop.

Select an option

Save dzhulk/11484321 to your computer and use it in GitHub Desktop.
class A
CONST = [1,2,3]
def call_it
CONST
end
def call_it2
self.class::CONST
end
end
class B < A
CONST = [0,1]
end
puts A::CONST.to_s #=> [1, 2, 3]
puts B::CONST.to_s #=> [0, 1]
puts A.new.call_it.to_s #=> [1, 2, 3]
puts B.new.call_it.to_s #=> [1, 2, 3]
puts A.new.call_it2.to_s #=> [1, 2, 3]
puts B.new.call_it2.to_s #=> [0, 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment