Why are `any` and `all` defined on `Array<out T...
# announcements
r
Why are
any
and
all
defined on
Array<out T>
instead of
Array<T>
?
k
I've been trying for about 10 minutes now but I can't find any combination where it makes any difference.
r
What?
k
I've tried to define my own version of
any
that isn't defined on
Array<out T>
but on
Array<T>
, but couldn't find a case where that didn't work exactly as the real one.
r
I expect it to work the same. My issue is that I have an
Array<T>
and can't use
any
because it's defined on
Array<out T>
i
Array<T>
is a subtype of
Array<out T>
, so any extensions for the latter are available for the former.
r
Hmm, that makes sense. I must have been doing something else wrong. I'll have to check when I get back to a computer.
k
@ilya-gh Why is it defined on
out
then if its the same either way?
r
@karelpeeters Wrong Ilya. You meant @ilya.gorbunov.
k
Dammit not again. Thanks!
i
We use out variance to emphasize that an out-projected array is enough for the particular operation.
k
And are there cases where it actually does something? Ie. does it allow more programs to compile?
i
It can make a difference in cases when there are more than one
T
position in a function signature.