There was an error while loading. Please reload this page.
1 parent 7046842 commit db59470Copy full SHA for db59470
library/src/scala/Array.scala
@@ -55,6 +55,19 @@ object Array {
55
*/
56
def newBuilder[T](implicit t: ClassTag[T]): ArrayBuilder[T] = ArrayBuilder.make[T](t)
57
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
+ */
71
def from[A : ClassTag](it: IterableOnce[A]): Array[A] = it match {
72
case it: Iterable[A] => it.toArray[A]
73
case _ => it.iterator.toArray[A]
0 commit comments