Skip to content

Instantly share code, notes, and snippets.

@brettchalupa
Forked from BanzaiMan/x.rb
Created May 16, 2015 14:22
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 brettchalupa/c5617725e50353462ac1 to your computer and use it in GitHub Desktop.
Save brettchalupa/c5617725e50353462ac1 to your computer and use it in GitHub Desktop.
class X
attr_accessor :i
def initialize
@i = 0
end
def work(e)
@i += e
end
def rest
@i = 0
end
end
x = X.new
x.work 5
x.work 7
puts x.i
x.rest
puts x.i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment