Jordan Carlyon03/30/2020, 6:27 PM
From the generics documentation
sealed class Result<out R>
The general rule is: when a type parameterof a class
Tis declared out, it may occur only in out-position in the members of
C, but in return
Ccan safely be a supertype of
In “clever words” they say that the classSo I can see that type parameteris covariant in the parameter
C, or that
Tis a covariant type parameter. You can think of C as being a producer of `T`'s, and NOT a consumer of `T`’s.
can only be returned by
but what is
? Is my assumption correct? I can see here that it is a callable reference
References to functions, properties, and constructors, apart from introspecting the program structure, can also be called or used as instances of function types.
The common supertype for all callable references isBut I am not sure what that is or why it matters here. Is this applicable to this sealed class or is this not considered a callable reference since it is a sealed class? Is the constructor the callable reference and then the return type is, where
KCallable<out R>is the return value type, which is the property type for properties, and the constructed type for constructors.
itnoles03/30/2020, 6:40 PM
Jordan Carlyon03/31/2020, 1:19 AM