Skip to content

Commit db59470

Browse files
committed
Add doc string to Array.from
1 parent 7046842 commit db59470

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

library/src/scala/Array.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,19 @@ object Array {
5555
*/
5656
def newBuilder[T](implicit t: ClassTag[T]): ArrayBuilder[T] = ArrayBuilder.make[T](t)
5757

58+
/** Build an array from the iterable collection.
59+
*
60+
* {{{
61+
* scala> val a = Array.from(Seq(1, 5))
62+
* val a: Array[Int] = Array(1, 5)
63+
*
64+
* scala> val b = Array.from(Range(1, 5))
65+
* val b: Array[Int] = Array(1, 2, 3, 4)
66+
* }}}
67+
*
68+
* @param it the iterable collection
69+
* @return an array consisting of elements of the iterable collection
70+
*/
5871
def from[A : ClassTag](it: IterableOnce[A]): Array[A] = it match {
5972
case it: Iterable[A] => it.toArray[A]
6073
case _ => it.iterator.toArray[A]

0 commit comments

Comments
 (0)