Hey, maybe somebody can help me: I try to create a...
# announcements
r
Hey, maybe somebody can help me: I try to create a property with a list of elements, where the element have to inherit from a specific class and has to implement a specific interface. I ended up in sth like this:
private val <T> buffer: List<T> where T : A, T : SomeInterface
Problem: this is not working since
T
is not used in "its receiver type" - can somebody help me with the correct syntax for my purpose?
s
you can’t really have call-site variance for vals
I’m not sure what you’re trying to do is possible in the first place
you may want a function instead, but I can’t say for sure
k
I think he wants an intersection type, not actual generics.
s
shame we can’t have
List<T | SomeInterface>
😕
k
More like
&
simple smile
r
no function is no option
s
@karelpeeters true
r
yes
private val buffer: List<A & SomeInterface>
would be another great option to show what I mean