summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2006-03-11 23:07:10 +0000
committerMartin Odersky <odersky@gmail.com>2006-03-11 23:07:10 +0000
commit7cb7defbd4063d6c4cbd42a9222f51fe09346dab (patch)
tree799a8fddde6fa6a71e96d286fa13bbe98f7ab79f /src/library
parent74d770b456e0d907b35fae994ee4acb4a7fd3d63 (diff)
downloadscala-7cb7defbd4063d6c4cbd42a9222f51fe09346dab.tar.gz
scala-7cb7defbd4063d6c4cbd42a9222f51fe09346dab.tar.bz2
scala-7cb7defbd4063d6c4cbd42a9222f51fe09346dab.zip
Bug fixes
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/List.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala
index 824e109a60..a2ea568f38 100644
--- a/src/library/scala/List.scala
+++ b/src/library/scala/List.scala
@@ -415,6 +415,19 @@ sealed abstract class List[+a] extends Seq[a] {
b.prependToList(this)
}
+ /** Converts the list to an Array */
+ def toArray[b >: a]: Array[b] = {
+ val xs = new Array[b](length)
+ var i = 0
+ var these = this
+ while (!these.isEmpty) {
+ xs(i) = these.head
+ i = i + 1
+ these = these.tail
+ }
+ xs
+ }
+
/** Reverse the given prefix and append the current list to that.
* This function is equivalent to an application of <code>reverse</code>
* on the prefix followed by a call to <code>:::</code>, but more