Skip to content

Commit 215bcb3

Browse files
Add documentation for some Tuple operations
1 parent e2148f4 commit 215bcb3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

library/src/scala/Tuple.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,18 @@ sealed trait Tuple extends Any {
3333
inline def size[This >: this.type <: Tuple]: Size[This] =
3434
DynamicTuple.dynamicSize(this)
3535

36+
/** Given two tuples, `(A1, ..., An)` and `(B1, ..., Bn)`, returns a tuple
37+
* `((A1, B1), ..., (An, Bn))`. If the two tuples have different sizes,
38+
* the extra elements of the larger tuple will be disregarded.
39+
*/
3640
inline def zip[This >: this.type <: Tuple, T2 <: Tuple](t2: T2): Zip[This, T2] =
3741
DynamicTuple.dynamicZip(this, t2)
3842

43+
/** Called on a tuple `(A1, ..., An)`, returns a new tuple of type
44+
* `(F[A1], ..., F[An])`. Each element of this tuple is the result
45+
* of application of function `f` to the corresponding element of the
46+
* callee tuple.
47+
*/
3948
inline def map[F[_]](f: [t] => t => F[t]): Map[this.type, F] =
4049
DynamicTuple.dynamicMap(this, f)
4150
}
@@ -79,6 +88,10 @@ object Tuple {
7988
case h *: t => F[h] *: Map[t, F]
8089
}
8190

91+
/** Given two tuples, `(A1, ..., An)` and `(B1, ..., Bn)`, returns a tuple
92+
* `((A1, B1), ..., (An, Bn))`. If the two tuples have different sizes,
93+
* the extra elements of the larger tuple will be disregarded.
94+
*/
8295
type Zip[T1 <: Tuple, T2 <: Tuple] <: Tuple = (T1, T2) match {
8396
case (h1 *: t1, h2 *: t2) => (h1, h2) *: Zip[t1, t2]
8497
case (Unit, _) => Unit

0 commit comments

Comments
 (0)