Skip to content

Instantly share code, notes, and snippets.

@mazur
Created June 9, 2011 19:16
Show Gist options
  • Save mazur/1017481 to your computer and use it in GitHub Desktop.
Save mazur/1017481 to your computer and use it in GitHub Desktop.
interface IOperator do
def run(x:int, y:int)
returns int
end
end
class Add
implements IOperator
def run(x:int, y:int)
returns int
x + y
end
end
class Sub
implements IOperator
def run(x:int, y:int)
returns int
x - y
end
end
class Operators
def add
Add.new
end
def sub
Sub.new
end
end
def calculate(op:IOperator)
op.run(4, 20)
end
ops = Operators.new
puts calculate ops.add
puts calculate ops.sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment