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

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"

解决方法

不,遗憾的是不可能做这样的事情 – CLR没有提供任何有效的方式来进行这种类型的测试.有些(相当难看的)解决方案请参见 How to cast an object to a list of generic type in F#F# and pattern matching on generics in a non-generic method implementing an interface.

相关文章

一:display:flex布局display:flex是一种布局方式。它即可以...
1. flex设置元素垂直居中对齐在之前的一篇文章中记载过如何...
移动端开发知识点pc端软件和移动端apppc端软件是什么,有哪些...
最近挺忙的,准备考试,还有其他的事,没时间研究东西,快周...
display:flex;把容器设置为弹性盒模型(设置为弹性盒模型之后...
我在网页上运行了一个Flex应用程序,我想使用Command←组合键...