Skip to content

Instantly share code, notes, and snippets.

@Phrogz
Created March 23, 2011 21:35
Show Gist options
  • Save Phrogz/884068 to your computer and use it in GitHub Desktop.
Save Phrogz/884068 to your computer and use it in GitHub Desktop.
class Foo
@@foo = nil
def self.seti( value )
@foo = value
end
def self.setc( value )
@@foo = value
end
def self.geti
@foo
end
def self.getc
@@foo
end
end
class Bar < Foo
end
p [ Foo.geti, Bar.geti, Foo.getc, Bar.getc ]
#=> [nil, nil, nil, nil]
Foo.seti :foo_i
Foo.setc :foo_c
p [ Foo.geti, Bar.geti, Foo.getc, Bar.getc ]
#=> [:foo_i, nil, :foo_c, :foo_c]
Bar.seti :bar_i
Bar.setc :bar_c
p [ Foo.geti, Bar.geti, Foo.getc, Bar.getc ]
#=> [:foo_i, :bar_i, :bar_c, :bar_c]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment