Created
August 25, 2014 10:22
-
-
Save liammclennan/41fad25b94a8161e6cab to your computer and use it in GitHub Desktop.
f# interfaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Library1 | |
open NUnit.Framework | |
open FsUnit | |
type IHaveAnAge = | |
abstract age: int | |
type Person = | |
{ name: string; age: int } | |
interface IHaveAnAge with | |
member x.age = x.age | |
type Tree = | |
{ species: string; rings: int } | |
interface IHaveAnAge with | |
member x.age = x.rings / 2 | |
let printAge (t:IHaveAnAge) = | |
t.age |> printfn "%A" | |
[<TestFixture>] | |
type Class1() = | |
[<Test>] | |
member this.X ()= | |
{ name = "Liam"; age = 31 } |> printAge | |
{ species = "Pine"; rings = 88 } |> printAge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment