Hey folks, I’ve got a method that takes, as one of...
# announcements
m
Hey folks, I’ve got a method that takes, as one of its arguments,
func: Function<Foo, Bar>
. Elsewhere in the code, when calling it, I’m trying to pass in
{ it.baz }
where it is type Foo, and baz is type Bar. But it’s giving me
unresolved reference: it
and saying that the type of the lambda is
() -> [ERROR:]
. If I prefix it with the word Function,
Function { it.baz}
it works.
a
Function<Foo, Bar>
is a java interface?
m
Yeah. I’m realizing now (trying to debug a coworker’s code) that he was using “kotlin.test.assertEquals”, which is <T,T> which is also breaking the compiler, because the literal on the left isn’t nullable. I thought that was junit’s assertEquals.
Why wouldn’t assertEquals take a nullable value?
Well, I solved it. By replacing the java
Function<Foo, Bar>
with
(Foo) -> Bar
👍 1