Kotlin String to Int array
When user convert list to string and again need that string to list. Due to space between integer app crashes with NumberFormatException for that just remove unnecessary space.
val result = "[1, 2, 3, 4, 5]".removeSurrounding("[","]").replace(" ","").split(",").map { it.toInt() }
Fortunately I've been able to make it work, so I'll leave it here for future reference
val result = "[1,2,3,4,5]".removeSurrounding("[", "]").split(",").map { it.toInt() }
Many thanks to all!