diff options
author | Paul Phillips <paulp@improving.org> | 2011-02-20 06:51:57 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-02-20 06:51:57 +0000 |
commit | fd1ca1e63c876046936f681be26730a301da8ff2 (patch) | |
tree | 6db9fac72b958af0df8c51eeae8478c0fe5b6a98 /src/library/scala/Tuple2.scala | |
parent | 6a570deed1790889f7036a00c045c15217313587 (diff) | |
download | scala-fd1ca1e63c876046936f681be26730a301da8ff2.tar.gz scala-fd1ca1e63c876046936f681be26730a301da8ff2.tar.bz2 scala-fd1ca1e63c876046936f681be26730a301da8ff2.zip |
Moved unlift to the Function companion object, ...
Moved unlift to the Function companion object, which might have been
better in the first place. Had to make a minor change to genprod, and
then I couldn't escape that unscathed. Finished the not very complete
undertaking I found there to update the scaladoc. Lots of little changes
to the generated text and code.
I changed genprod to only put a unique stamp on Function0 so we can stop
having a 100 file diff everytime an i is dotted somewhere.
Closes #3825, no review.
Diffstat (limited to 'src/library/scala/Tuple2.scala')
-rw-r--r-- | src/library/scala/Tuple2.scala | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/library/scala/Tuple2.scala b/src/library/scala/Tuple2.scala index 9652f2e602..fc9b348fdb 100644 --- a/src/library/scala/Tuple2.scala +++ b/src/library/scala/Tuple2.scala @@ -5,8 +5,7 @@ ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ - -// generated by genprod on Wed Oct 27 14:26:15 PDT 2010 (with extra methods) +// GENERATED CODE: DO NOT EDIT. See scala.Function0 for timestamp. package scala @@ -14,17 +13,21 @@ import scala.collection.{ TraversableLike => TLike, IterableLike => ILike } import scala.collection.generic.{ CanBuildFrom => CBF } - - -/** Tuple2 is the canonical representation of a @see Product2 +/** A tuple of 2 elements; the canonical representation of a [[scala.Product2]]. * + * @constructor Create a new tuple with 2 elements. Note that it is more idiomatic to create a Tuple2 via `(t1, t2)` + * @param _1 Element 1 of this Tuple2 + * @param _2 Element 2 of this Tuple2 */ -case class Tuple2[@specialized(Int, Long, Double) +T1, @specialized(Int, Long, Double) +T2](_1:T1,_2:T2) +case class Tuple2[@specialized(Int, Long, Double) +T1, @specialized(Int, Long, Double) +T2](_1: T1, _2: T2) extends Product2[T1, T2] { override def toString() = "(" + _1 + "," + _2 + ")" - /** Swap the elements of the tuple */ + /** Swaps the elements of this `Tuple`. + * @return a new Tuple where the first element is the second element of this Tuple and the + * second element is the first element of this Tuple. + */ def swap: Tuple2[T2,T1] = Tuple2(_2, _1) @deprecated("Use `zipped` instead.") @@ -34,7 +37,16 @@ case class Tuple2[@specialized(Int, Long, Double) +T1, @specialized(Int, Long, D zipped map ((x, y) => ((x, y))) } - /** Wraps a tuple in a `Zipped`, which supports 2-ary generalisations of map, flatMap, filter,... + /** Wraps a tuple in a `Zipped`, which supports 2-ary generalisations of `map`, `flatMap`, `filter`, etc. + * Note that there must be an implicit value to convert this tuple's types into a [[scala.collection.TraversableLike]] + * or [[scala.collection.IterableLike]]. + * {{{ + * scala> val tuple = (List(1,2,3),List('a','b','c')) + * tuple: (List[Int], List[Char]) = (List(1, 2, 3),List(a, b, c)) + * + * scala> tuple.zipped map { (x,y) => x + ":" + y } + * res6: List[java.lang.String] = List(1:a, 2:b, 3:c) + * }}} * * @see Zipped * $willNotTerminateInf |