Scala Library: scala.Product1
scala.Product1
trait Product1[+T1] extends Product
Product1 is a cartesian product of 1 component.
- Source
- Since
- 2.3
Abstract Value Members From scala.Equals
abstract def canEqual(that: Any): Boolean
A method that should be called from every well-designed equals method that is open to be overridden in a subclass. See Programming in Scala, Chapter 28 for discussion and design.
- that
- the value being probed for possible equality
- returns
- true if this instance can possibly equal
that
, otherwise false
- true if this instance can possibly equal
- Definition Classes
- Equals
(defined at scala.Equals)
Concrete Value Members From scala.Product1
abstract def _1: T1
A projection of element 1 of this Product.
- returns
- A projection of element 1.
(defined at scala.Product1)
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
- Product1 → Product
- Annotations
- @ throws (clazz = classOf[IndexOutOfBoundsException])
- Exceptions thrown * (defined at scala.Product1)
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
object Product1 {
def unapply[T1](x: Product1[T1]): Option[Product1[T1]] =
Some(x)
}
/** Product1 is a cartesian product of 1 component.
* @since 2.3
*/
trait Product1[@specialized(Int, Long, Double) +T1] extends Any with Product {
/** The arity of this product.
* @return 1
*/
override def productArity = 1
/** Returns the n-th projection of this product if 0 < n <= productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
* @return same as `._(n+1)`, for example `productElement(0)` is the same as `._1`.
* @throws IndexOutOfBoundsException
*/
@throws(classOf[IndexOutOfBoundsException])
override def productElement(n: Int) = n match {
case 0 => _1
case _ => throw new IndexOutOfBoundsException(n.toString())
}
/** A projection of element 1 of this Product.
* @return A projection of element 1.
*/
def _1: T1
}
Interested in Scala?
I send out weekly, personalized emails with articles and conference talks.
Subscribe now.