class Function1<A : Number, R : Number>(val func: (a: A) -> R) {
operator fun invoke(a: A): R = func(a)
}
why
::invoke
seems to require a parameter of type
Nothing
here:
Copy code
when(val f = t.function) {
is Function1<*, *> -> f.invoke(stack.pop()) // Type mismatch: required Nothing
}
Because of the
<*, *>
? I cant specify anything else because of type erasure
this works though
Copy code
is Function1<*, *> -> (f as Function1<Number, Number>)(stack.pop())
m
Michael de Kaste
05/20/2020, 9:43 AM
if your function doesn't know what type it is; you can't call the result of the function without it being Nothing.
What are you testing with "is Function<*, *>" exactly?
e
elect
05/20/2020, 9:49 AM
basically is the number of parameters passed to the