Skip to content

Instantly share code, notes, and snippets.

@emiltin
Created April 15, 2010 20:46
Show Gist options
  • Save emiltin/367628 to your computer and use it in GitHub Desktop.
Save emiltin/367628 to your computer and use it in GitHub Desktop.
class A
attr_accessor :value
def initialize v=0
@value = v
end
def + other
A.new( @value + other.value)
end
def to_i
@value
end
end
a=A.new(5)
b=A.new(3)
c=A.new(2)
puts (a+b+c).to_i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment