String Split in Kotlin

Level 274 keystrokes

Splits a string at a delimiter and prints each part.

Kotlin code

// A string of comma-separated values
1val text = "a,b,c"
// split(",") cuts the string at each comma and returns List<String> ["a", "b", "c"]
2val parts = text.split(",")
// Prints each part on its own line
3for (p in parts) println(p)

Output

a
b
c
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Kotlin code and how often they appear.

  • "× 4
  • ,× 3
  • (× 3
  • )× 3
  • =× 2
  • .× 1

More Kotlin examples at level 2

← Kotlin typing practice