https://kotlinlang.org logo
#getting-started
Title
# getting-started
l

Lukasz Kalnik

02/15/2022, 2:59 PM
How do I convert a
List<Int>
to an
IntArray
(not
Array<Int>
)?
l

Lukasz Kalnik

02/15/2022, 3:02 PM
Ah, I was wondering why it doesn't show up in code completion. But I had a
Map<Int, Int>
which I converted using
toList()
and it's obviously a
List<Pair<Int, Int>>
. So I first have to map it to list of the map's keys (for example) 🤦
Thanks for the hint though!
g

gildor

02/15/2022, 3:05 PM
map.keys.toIntArray() should do the trick
l

Lukasz Kalnik

02/15/2022, 3:07 PM
Thanks!
3 Views