Vladyslav Sitalo

09/16/2018, 2:02 PM
I have an java interop question: I have a Kotlin function that accepts vararg argument (i.e.
fun processStrings(vararg strings: String)...
When I try to call it from Java though it’s seen as a function that accepts an array of strings instead of vararg function. Is there a way to make this function accept vararg from Java’s perspective?


09/16/2018, 2:11 PM
maybe there is a annotation, but something that should work for sure is passing a array eg:
String[] {"arguments", "here"}
at least i think thats how you do array literals in java, been a while

Vladyslav Sitalo

09/16/2018, 2:29 PM
sure, passing the array works, but it’s rather cumbersome
I wonder why it get’s represented differently in a first place, given that both languages have vararg support that seems very similar =\
Ah, it’s more interesting that that, the case I mentioned above actually works ok. The case where I’m experiencing the problem is when I have vararg as a first argument and then a lambda as the second. In which case this behaviour kind of makes sense, given that there is no special last place lambda synthax or named parameters in java