Kotlin: convert array to Java varargs

How to convert my Kotlin Arrayto Java varargs String[]?

val angularRoutings = 
    arrayOf<String>("/language", "/home")

// this doesn't work        
web.ignoring().antMatchers(angularRoutings)

How to pass an ArrayList to a varargs method parameter?

+17
source share
1 answer

You should use the “ distribution operator ”, which is as follows: *
The distribution operator must be the prefix of the array argument:

antMatchers(*angularRoutings)

For more information, see the documentation :

vararg -, , . asList(1, 2, 3) , , ( *):

+28

Source: https://habr.com/ru/post/1686383/


All Articles