Skip to content

Instantly share code, notes, and snippets.

@mgreenly
Created May 14, 2011 00:35
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 mgreenly/971546 to your computer and use it in GitHub Desktop.
Save mgreenly/971546 to your computer and use it in GitHub Desktop.
ruby class instance variables
class Foo
# create class instance variables
class << self;
attr_accessor :bar;
end
#initialize class instance variables
@bar = 42
# use class instance variables in class methods
def self.inc_bar
@bar += 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment