Would be great, foo bar
# announcements
l
Would be great, foo bar
r
liminal: basically,
in
and
out
tell the compiler whether your function or class produces a generic, or consumes it
If you have this:
fun <T> hello(): T { }
, you'll be told that T can be marked
out
Because
hello()
doesn't consume, or have any parameters of type T
It just produces an instance of T
Flip side,
fun <T> hello(thing: T): String { }
, you'll be told T can be marked
in
You consume, or take a parameter of type T
And don't produce it
Something in the middle wouldn't need variance at all, because it produces and consumes
fun <T> hello(inst: T): T { }
is an example of that
l
I see. Thanks!
t
nice explanation, thanks!
a
@redrield Could you please also explain what do you gain by marking the variance? Is it important for some reason?