Created
April 20, 2018 01:29
-
-
Save isaksky/5068bd18a401fc872e4191666b8909ca to your computer and use it in GitHub Desktop.
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
type Base() = | |
member x.Method() = "base method"; | |
type Derived() = | |
inherit Base() | |
member x.Method() = "derived method" | |
type Base with | |
member x.Extension() = "base extension" | |
type Derived with | |
member x.Extension() = "derived extension" | |
let a = Base() | |
let b = Derived() | |
printfn "%s" (a.Method()) | |
printfn "%s" (b.Method()) | |
printfn "%s" (a.Extension()) | |
printfn "%s" (b.Extension()) | |
(* | |
base method | |
derived method | |
base extension | |
derived extension | |
*) | |
Correction:
let a = Base()
let b = Derived() :> Base
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Woops, saw that I misread - the
let b
should be upcast to Base.