this shit `<*>` bugged af
# getting-started
w
this shit
<*>
bugged af
d
<*>
works just fine. In your constructor you can declare the parameter type as
Collection<*>
. However when calling it (i.e. creating the collection) you need to actually specify the type, this is the same as in Java.
w
you can do just new Arraylist<>()
d
If the type can be inferred, yes.
Or do you mean in Java? If so, yes, but that's actually terrible behavior. It will just silently fall back to
Object
.
w
yes in java
d
Kotlin equivalent would be
ArrayList<Any>()
.
Not sure what the point is there though, you will never be able to insert anything into this list inside the
PacketWrapper
instance, you can only read from it (but it's empty).
w
It worked somehow months ago
I didn't even write it
just maintaining it from now on in Kotlin ^^
d
What exactly worked?
w
the PacketWrapper constructor
d
Well, it works the same in Kotlin... Replace
<?>
with
<*>
.
Kotlin just won't let you get away with raw types or non-inferrable types.
w
ya
kinda unusual for me; thanks for the explanation