Wonder what is wrong with specifying Kotlin function parameter name when calling a function. In some situation it won’t work and I don’t know how to fix it.
For example, this code works fine without specifying the parameters’ names:
assertEquals(
FakeDataSource.photosList,
repository.getMarsPhotos(),
)
But the same code with parameters name give me a compiler error:
assertEquals(
expected = FakeDataSource.photosList,
actual = repository.getMarsPhotos(),
)
>Solution :
The Kotlin documentation tells us this:
When calling Java functions on the JVM, you can’t use the named argument syntax because Java bytecode does not always preserve the names of function parameters.
You are calling a JUnit method there, written in Java.
