Pair Type in Kotlin

Level 268 keystrokes

Creates a Pair and reads its two components.

Kotlin code

// Pair holds exactly two values, which may have different types
1val pair = Pair("name", 42)
// first is the first value: name
2println(pair.first)
// second is the second value: 42
3println(pair.second)

Output

name
42
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.

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

More Kotlin examples at level 2

← Kotlin typing practice