You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since it never mutates the array and simply creates a list, main(args: Array<String>) should ideally be main(args: Array<out String>). This will improve the compatibility with the three ways you can define the parameter for a normal main method.
Here's an illustrative example:
funtestMain(varargvarargString:String) {
val arrayString:Array<String> = emptyArray()
val arrayOutString:Array<outString> = emptyArray()
exampleNoOut(varargString)
exampleNoOut(arrayString)
exampleNoOut(arrayOutString)
exampleOut(varargString)
exampleOut(arrayString)
exampleOut(arrayOutString)
}
funexampleNoOut(args:Array<String>) =UnitfunexampleOut(args:Array<outString>) =Unit
And what it looks like in the IDE:
This is a binary-compatible change since variance is a concept solely implemented in the compiler (like generics in general). It also should be a source-compatible change as you can see above, but also because Array<out String> is more permissive than Array<String> in what it accepts.
The text was updated successfully, but these errors were encountered:
Since it never mutates the array and simply creates a list,
main(args: Array<String>)
should ideally bemain(args: Array<out String>)
. This will improve the compatibility with the three ways you can define the parameter for a normalmain
method.Here's an illustrative example:
And what it looks like in the IDE:
This is a binary-compatible change since variance is a concept solely implemented in the compiler (like generics in general). It also should be a source-compatible change as you can see above, but also because
Array<out String>
is more permissive thanArray<String>
in what it accepts.The text was updated successfully, but these errors were encountered: