Skip to content

Instantly share code, notes, and snippets.

@isaksky
Created April 20, 2018 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaksky/5068bd18a401fc872e4191666b8909ca to your computer and use it in GitHub Desktop.
Save isaksky/5068bd18a401fc872e4191666b8909ca to your computer and use it in GitHub Desktop.
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
*)
@isaksky
Copy link
Author

isaksky commented Apr 20, 2018

Woops, saw that I misread - the let b should be upcast to Base.

@isaksky
Copy link
Author

isaksky commented Apr 20, 2018

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