Why won't this work? LegalMenu is an enum.
# announcements
j
Why won't this work? LegalMenu is an enum.
Neither does generic work 😕
r
because (despite how it might look),
Array<Any>
is NOT super type of
Array<LegalMenu>
, despite
Any
being super type of
LegalMenu
-
Array<T>
is invariant in
T
- no
out
or
in
modifier on it, so every diff
Array<T>
is a different type and there is no relations between them
the generics should definitely be accepted tho, how are ya defining them?
j
Actually I got this to work with
Array<*>
LegalMenu is just a simple enum class in Java
I assume
*
is equivalent to java's
Object
r
*
is more like equivalent to Java's
?
in generics
anyways, smth like this works:
Copy code
fun<T> f(a: Array<T>): Unit = TODO()

enum class Test {
    A, B, C
}

f(Test.values())
so dunno how you defined the generics...
👍 1