Convert array to list in Kotlin

I am trying to do this with (similar to java)

val disabledNos = intArrayOf(1, 2, 3, 4) var integers = Arrays.asList(disabledNos) 

but it does not give me a list. Any ideas?

+5
source share
2 answers

Kotlin supports the standard library for this conversion.

You can directly use

 disableNos.toList() 

or if you want to change it:

 disableNos.toMutableList() 
+17
source

It is very simple:

 var integers = Arrays.asList(disabledNos).toList() 
-1
source

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


All Articles