https://kotlinlang.org logo
#getting-started
Title
# getting-started
l

Lucas

07/20/2022, 1:48 PM
Can anyone tell me what is wrong with this?
c

Chris Lee

07/20/2022, 1:55 PM
hard to say without seeing the code. at a glance: the “required” type is nullable, the “found” type is not.
l

Lucas

07/20/2022, 1:58 PM
Yeah but should that really be a problem? I own the required type, making it non nullable doesnt solve it
image.png
This doesnt make sense to me
making "Any" non nullable doesnt change anything
This works, oddly enough
m

MR3Y

07/20/2022, 2:23 PM
arrayOf(arrayOf(1))
isn't compiling as expected in your code unless you specify the exact same type
Array<Array<Any?>>
explicitly because the type parameter of Array in Kotlin is invariant, it is actually declared as
Array<T>
not
Array<out T>
, the latter is equivalent to Array<? extends T> Source: https://github.com/JetBrains/kotlin/blob/ea836fd46a1fef07d77c96f9d7e8d7807f793453/core/builtins/native/kotlin/Array.kt#L15
👍 1