F# and duck-typing

后端 未结 3 628
一向
一向 2021-01-04 02:30

Let\'s say I defined in F# the following two types:

type Dog = { DogName:string; Age:int }
type Cat = { CatName:string; Age:int }

I was exp

3条回答
  •  隐瞒了意图╮
    2021-01-04 03:03

    FSharp.Interop.Dynamic (on nuget) provides a DLR based implementation of the dynamic operator (real dynamic duck typing)

    let isOld x = x?Age >= 65
    

提交回复
热议问题