KT-20357 Add sample code for Pair/Triple.toList

This commit is contained in:
takasy
2018-08-06 20:43:12 +09:00
committed by Ilya Gorbunov
parent f41b410e1d
commit 76a98c8e67
2 changed files with 25 additions and 0 deletions
@@ -44,6 +44,7 @@ public infix fun <A, B> A.to(that: B): Pair<A, B> = Pair(this, that)
/**
* Converts this pair into a list.
* @sample samples.misc.Tuples.pairToList
*/
public fun <T> Pair<T, T>.toList(): List<T> = listOf(first, second)
@@ -76,5 +77,6 @@ public data class Triple<out A, out B, out C>(
/**
* Converts this triple into a list.
* @sample samples.misc.Tuples.tripleToList
*/
public fun <T> Triple<T, T, T>.toList(): List<T> = listOf(first, second, third)