Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Animals.fs « mdoc.Test.FSharp « mdoc.Test « mdoc - github.com/mono/api-doc-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8cc5ae6c8dad900921e972144d56090f19d265c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Animals

// Call a base class from a derived one.
type Animal() =
    member __.Rest() = ()

type Dog() =
    inherit Animal()
    member __.Run() =
        base.Rest()

// Upcasting is denoted by :> operator.
let dog = Dog() 
let animal = dog :> Animal

//Dynamic downcasting (:?>) might throw an InvalidCastException if the cast doesn't succeed at runtime.
let shouldBeADog = animal :?> Dog