You can use padStart:
(0..1000)
.map { it.toString().padStart(4, '0') }
.forEach(::println)
It’s part of the Kotlin Standard Library and available for all platforms.
You can use padStart:
(0..1000)
.map { it.toString().padStart(4, '0') }
.forEach(::println)
It’s part of the Kotlin Standard Library and available for all platforms.