Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Boo 中是否有一种方法可以像使用 C# 中的 where 子句那样表达泛型类型的一些约束?
简而言之,怎么写?:
class MyClass<T> where T:Icomparable<T> {...}
谢谢
是的。语法与声明基类型相同:
class MyClass[of T(IComparable of T)]
或者,对于其他约束:
class MyClass[of T1(class, constructor), T2(struct)]
我认为 Boo 的当前开发版本不支持引用自身或其他泛型类型参数的泛型类型参数约束;不过我可能弄错了。
是的,这是可能的。看: