Kotlin: Convert a list to a String (joinToString syntax/example)

Here’s a little Kotlin joinToString example. First, a sample list to work with:

val nums = listOf(1,2,3,4,5)

Then here’s the joinToString example:

    separator = ", ",
    prefix = "[",
    postfix = "]",
    limit = 3,
    truncated = "there’s more ..."

When you put all of that code in the Kotlin REPL you’ll see this result: