Skip to content
Alex Zuzin edited this page Apr 13, 2017 · 2 revisions

Tuples can be made as follows:

val oneTuple = tuple(1)
val twoTuple = tuple(1, "2")
val threeTuple = tuple(1, "2", false)
//  ... all the way to an 8-tuple

Two-tuples can also be created from, and converted to Kotlin Pairs:

val twoTuple = (1 to "2").tuple()
val twoPair = twoTuple.pair()

A Kotlin Iterable of any arity Tuples can be sequenced as follows:

val tupleOfSeqs: Tuple2<Seq<Int>, Seq<String>> = 
   listOf(tuple(1, "2"), tuple(3, "4")).sequence()
Clone this wiki locally