Object expression
Introduction
let makeResource (resourceName: string) =
printfn $"create {resourceName}"
{ new System.IDisposable with
member _.Dispose() =
printfn $"dispose {resourceName}" }Interface singleton
[<Interface>]
type IConsole =
abstract ReadLine : unit -> string
abstract WriteLine : string -> unit
let console =
{ new IConsole with
member this.ReadLine () = Console.ReadLine ()
member this.WriteLine line = printfn "%s" line }Implementing several interfaces
Last updated