diff options
author | Burak Emir <emir@epfl.ch> | 2006-11-05 02:53:14 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2006-11-05 02:53:14 +0000 |
commit | 1e23988361e85f275b44041207988ef9aa0099f2 (patch) | |
tree | 167c7224dfbec04561337d771226fd678a3d1ae0 /src/library/scala/Product.scala | |
parent | 9d507e381c8c101a3edf16e0c065e9b8efd5feec (diff) | |
download | scala-1e23988361e85f275b44041207988ef9aa0099f2.tar.gz scala-1e23988361e85f275b44041207988ef9aa0099f2.tar.bz2 scala-1e23988361e85f275b44041207988ef9aa0099f2.zip |
caseclass->product
Diffstat (limited to 'src/library/scala/Product.scala')
-rw-r--r-- | src/library/scala/Product.scala | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/library/scala/Product.scala b/src/library/scala/Product.scala new file mode 100644 index 0000000000..07bc5b045c --- /dev/null +++ b/src/library/scala/Product.scala @@ -0,0 +1,42 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: CaseClass.scala 8756 2006-09-22 16:00:23Z michelou $ + + +package scala + +/** The trait <code>CaseClass</code> defines access functions for instances + * of case classes. + * + * @author Burak Emir + * @version 1.0 + */ +trait Product extends AnyRef { + + /** for a case class <code>A(x_1,...,x_k))</code>, returns <code>x_i</code> + * for <code>1 <= i < k</code> + * + * @param n the position of the n-th element + * @throws IndexOutOfBoundsException + * @return ... + */ + def element(n: Int): Any + + /** return k for a product <code>A(x_1,...,x_k))</code> + */ + def arity: Int + + /** + * By default the empty string. Implementations may override this + * method in order to prepend a string prefix to the result of the + * toString methods. + */ + def productPrefix = "" + +} |