diff options
author | Lex Spoon <lex@lexspoon.org> | 2007-03-24 14:40:49 +0000 |
---|---|---|
committer | Lex Spoon <lex@lexspoon.org> | 2007-03-24 14:40:49 +0000 |
commit | 9347b21b292958799f0c9ccceb6a624d1f87b7a5 (patch) | |
tree | bfe449a31dc7520eb526a0ac16b03177f0e9fa1e /src | |
parent | 7afac73a71578bb9b202528e070bda89ba767504 (diff) | |
download | scala-9347b21b292958799f0c9ccceb6a624d1f87b7a5.tar.gz scala-9347b21b292958799f0c9ccceb6a624d1f87b7a5.tar.bz2 scala-9347b21b292958799f0c9ccceb6a624d1f87b7a5.zip |
- tweaked two comments
- added toArray
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/Iterable.scala | 15 |
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. |