Skip to content

Instantly share code, notes, and snippets.

@danneu
Created October 11, 2012 19:23
Show Gist options
  • Save danneu/3874881 to your computer and use it in GitHub Desktop.
Save danneu/3874881 to your computer and use it in GitHub Desktop.
class ExampleClass
@variable = "foo"
@@variable = "bar"
def initialize
@variable = "baz"
end
def self.test
puts @variable
end
def test
self.class.test
puts @@variable
puts @variable
end
end
class ExampleSubclass < ExampleClass
@variable = "1"
@@variable = "2"
def initialize
@variable = "3"
end
end
first_example = ExampleClass.new
first_example.test
puts "---"
second_example = ExampleSubclass.new
second_example.test
foo
2
baz
---
1
2
3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment