Skip to content

Instantly share code, notes, and snippets.

@alexparker
Created November 23, 2013 06:16
Show Gist options
  • Save alexparker/7611432 to your computer and use it in GitHub Desktop.
Save alexparker/7611432 to your computer and use it in GitHub Desktop.
class Thing
attr_accessor :quantity
def initialize
@quantity = 100
end
def decrement(qty)
difference = quantity - qty
quantity = difference
end
end
irb(main):012:0> thing = Thing.new
=> #<Thing:0x007fc84b2ed928 @quantity=100>
irb(main):013:0> thing.quantity
=> 100
irb(main):014:0> thing.decrement(10)
=> 90
irb(main):015:0> thing.quantity
=> 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment