Scala Library: scala.Tuple2
scala.Tuple2
case class Tuple2[+T1, +T2](_1: T1, _2: T2) extends Product2[T1, T2] with Product with Serializable
A tuple of 2 elements; the canonical representation of a scala.Product2.
- _1
- Element 1 of this Tuple2
- _2
- Element 2 of this Tuple2
- Annotations
- @ deprecatedInheritance (message =…, since = “2.11.0”)
- Source
Value Members From scala.Product2
def productElement(n: Int): Any
Returns the n-th projection of this product if 0 < n <= productArity, otherwise
throws an IndexOutOfBoundsException
.
- n
- number of the projection to be returned
- returns
- same as
._(n+1)
, for exampleproductElement(0)
is the same as._1
.
- same as
- Definition Classes
- Product2 → Product
- Annotations
- @ throws (clazz = classOf[IndexOutOfBoundsException])
- Exceptions thrown *
(defined at scala.Product2)
Instance Constructors From scala.Tuple2
new Tuple2(_1: T1, _2: T2)
Create a new tuple with 2 elements. Note that it is more idiomatic to create a
Tuple2 via (t1, t2)
- _1
- Element 1 of this Tuple2
- _2
- Element 2 of this Tuple2
(defined at scala.Tuple2)
Value Members From Implicit scala.Predef.tuple2ToZippedOps
def invert[El1, CC1[X] <: TraversableOnce[X], El2, CC2[X] <: TraversableOnce[X], That](implicit w1: <:<[T1, CC1[El1]], w2: <:<[T2, CC2[El2]], bf: CanBuildFrom[CC1[_], (El1, El2), That]): That
- Implicit information
- This member is added by an implicit conversion from (T1, T2) to Ops [T1, T2] performed by method tuple2ToZippedOps in scala.Predef.
- Definition Classes
- Ops
(added by implicit convertion: scala.Predef.tuple2ToZippedOps)
def zipped[El1, Repr1, El2, Repr2](implicit w1: (T1) ⇒ TraversableLike[El1, Repr1], w2: (T2) ⇒ IterableLike[El2, Repr2]): Tuple2Zipped[El1, Repr1, El2, Repr2]
- Implicit information
- This member is added by an implicit conversion from (T1, T2) to Ops [T1, T2] performed by method tuple2ToZippedOps in scala.Predef.
- Definition Classes
- Ops (added by implicit convertion: scala.Predef.tuple2ToZippedOps)
Full Source:
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// GENERATED CODE: DO NOT EDIT. See scala.Function0 for timestamp.
package scala
/** 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
*/
@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple2[@specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) +T1, @specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) +T2](_1: T1, _2: T2)
extends Product2[T1, T2]
{
override def toString() = "(" + _1 + "," + _2 + ")"
/** 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)
}
Interested in Scala?
I send out weekly, personalized emails with articles and conference talks.
Subscribe now.