gpt4 book ai didi

f# - 使用 'flexible' 类型参数对泛型类型进行模式匹配

转载 作者:行者123 更新时间:2023-12-04 13:29:26 24 4
gpt4 key购买 nike

match value with
| :? list<#SomeType> as l -> l //Is it possible to match any list of a type derived from SomeType?
| _ -> failwith "doesn't match"

最佳答案

根据F# 2.0 specification , 标准杆。 14.5.2(解决子类型约束),它不起作用,因为:“F#泛型类型不支持协变或逆变。”

关于f# - 使用 'flexible' 类型参数对泛型类型进行模式匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3764867/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com