if a type is passed as a paramater : Any, is its o...
# getting-started
s
if a type is passed as a paramater : Any, is its original type lost?
s
This is an XY problem. Your approach is flawed. If you’re trying to double the length of a list, you can’t create a default value out of nowhere. Pass a default value to the function and use that, or pass a lambda that creates a default value
I’d also like to add that I don’t know why you’ve ignored suggestions to learn via the koans and have instead continued to hammer at this attempted solution which cannot work
We’re not here to teach you kotlin. There are resources you can use to learn, and we can point you towards those
s
so it is basically impossible to determine the original type of a variable that is passed as a parameter?
d
Boxed and unboxed versions of
Int
are used interchangeably. When passed as
Any
it must be boxed. You can use https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/java-primitive-type.html to get the primitive java class from either boxed or unboxed.
s
ok