summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLex Spoon <lex@lexspoon.org>2007-03-24 14:40:49 +0000
committerLex Spoon <lex@lexspoon.org>2007-03-24 14:40:49 +0000
commit9347b21b292958799f0c9ccceb6a624d1f87b7a5 (patch)
treebfe449a31dc7520eb526a0ac16b03177f0e9fa1e
parent7afac73a71578bb9b202528e070bda89ba767504 (diff)
downloadscala-9347b21b292958799f0c9ccceb6a624d1f87b7a5.tar.gz
scala-9347b21b292958799f0c9ccceb6a624d1f87b7a5.tar.bz2
scala-9347b21b292958799f0c9ccceb6a624d1f87b7a5.zip
- tweaked two comments
- added toArray
-rw-r--r--src/library/scala/Iterable.scala15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/library/scala/Iterable.scala b/src/library/scala/Iterable.scala
index 7626c469e7..4319157989 100644
--- a/src/library/scala/Iterable.scala
+++ b/src/library/scala/Iterable.scala
@@ -16,7 +16,7 @@ import Predef.IllegalArgumentException
import collection.mutable.{Buffer,ArrayBuffer}
import compat.StringBuilder
-/** This object ...
+/** Various utilities for instances of <a href="Iterable.html">Iterable</a>.
*
* @author Matthias Zenger
* @version 1.1, 04/02/2004
@@ -335,10 +335,21 @@ trait Iterable[+A] {
}
/**
- * @return a list with all the elements of this iterable object
+ * Create a fresh list with all the elements of this iterable object
*/
def toList: List[A] = elements.toList
+
+ /**
+ * Creates an array with the elements of this iterable,
+ * in the order the iterable provides them.
+ */
+ def toArray[B >: A]: Array[B] = {
+ val result = new ArrayBuffer[B]
+ result ++ this
+ result.toArray
+ }
+
/** Returns a string representation of this iterable object. The resulting string
* begins with the string <code>start</code> and is finished by the string
* <code>end</code>. Inside, the string representations of elements (w.r.t.