diff options
author | Burak Emir <emir@epfl.ch> | 2006-11-28 15:15:08 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2006-11-28 15:15:08 +0000 |
commit | c5e9360725ed37e444b3836185be895bc69e5687 (patch) | |
tree | 203868a7a631cd47c9d6b331c536e20b02a141b9 /src/library | |
parent | 61ef5c893f9f4cab1e9250d91f5d4210594366c2 (diff) | |
download | scala-c5e9360725ed37e444b3836185be895bc69e5687.tar.gz scala-c5e9360725ed37e444b3836185be895bc69e5687.tar.bz2 scala-c5e9360725ed37e444b3836185be895bc69e5687.zip |
more fun with Product.element and positions
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/runtime/ScalaRunTime.scala | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index f0b5eb3ddc..1ac8180a5e 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -71,9 +71,9 @@ object ScalaRunTime { def caseFields(x: Product): List[Any] = { val arity = x.arity; def fields(from: Int): List[Any] = - if (from > arity) List() + if (from == arity) List() else x.element(from) :: fields(from + 1); - fields(1) + fields(0) } def _toString(x: Product): String = { @@ -83,8 +83,8 @@ object ScalaRunTime { def _hashCode(x: Product): Int = { var code = x.getClass().hashCode(); val arr = x.arity - var i = 1; - while (i <= arr) { + var i = 0; + while (i < arr) { code = code * 41 + x.element(i).hashCode(); i = i + 1 } @@ -95,10 +95,10 @@ object ScalaRunTime { case y1: Product if x.arity == y1.arity => /*(x.getClass() eq y1.getClass() &&*/ { val arity = x.arity; - var i = 1; - while (i <= arity && x.element(i) == y1.element(i)) + var i = 0; + while (i < arity && x.element(i) == y1.element(i)) i = i + 1; - i == arity + 1 + i == arity } case _ => false |