Skip to content

Instantly share code, notes, and snippets.

@SteveGilham
Created April 26, 2015 13:48
[<AbstractClass>]
type AbstractPoint
= class
val mutable vx: int;
val mutable vy: int;
new(x,y) = { vx = x; vy = y }
member p.x with get() = p.vx and set z = p.vx <- z
member p.y with get() = p.vy and set z = p.vy <- z
abstract move: AbstractPoint -> unit
end
type Point'
= class
inherit AbstractPoint
new(x,y) = { inherit AbstractPoint(x,y) }
override p.move q = p.x <- p.x + q.x;
p.y <- p.y + q.y
end
let p = Point'(2,3)
let q = Point'(1,2)
p.move(q)
p.x
p.y;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment