carlhung
(Carlhung)
1
T conforms Collection and AnyObject. I want to know if I subclass Base if I can make the subclass's placeHolder inherit the superclass's placeholder?
example:
class Base<T: Collection & AnyObject> {
var val: T
init(val: T) {
self.val = val
}
}
T is the superclass's placeholder, T.
class Sub<U: T & Comparable>: Base<U> {
}
How can I do something like this?
jrose
(Jordan Rose)
2
There’s not an automatic way to do this today; you’ll just have to redeclare the Collection and AnyObject constraints on U alongside Comparable.
1 Like