Skip to content

Instantly share code, notes, and snippets.

@rightgo09
Created March 31, 2016 01:45
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 rightgo09/2916de8b9e27ead2f9a711c7a1eab6fa to your computer and use it in GitHub Desktop.
Save rightgo09/2916de8b9e27ead2f9a711c7a1eab6fa to your computer and use it in GitHub Desktop.
class Hoge
def get_v
@@v ||= 123
end
class << self
def inc_v
@@v ||= 0
@@v += 1
end
end
end
Hoge.new.get_v #=> 123
Hoge.inc_v #=> 124
Hoge.new.get_v #=> 124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment