Skip to content

Instantly share code, notes, and snippets.

@SteveGilham
Created April 26, 2015 13:48

Revisions

  1. SteveGilham created this gist Apr 26, 2015.
    23 changes: 23 additions & 0 deletions gistfile1.fs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    [<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;;