-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Array.from extension for scala 2.11 and 2.12 #658
Conversation
6afa36a
to
f566425
Compare
review by @scala/collections ? |
@@ -357,6 +360,11 @@ private[compat] trait PackageShared { | |||
new RandomExtensions(self) | |||
} | |||
|
|||
class ArrayExtensions(private val fact: Array.type) extends AnyVal { | |||
def from[A: ClassTag](source: TraversableOnce[A]): Array[A] = | |||
fact.apply(source.toSeq: _*) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source match {
case it: Iterable[A] => it.toArray[A]
case _ => it.iterator.toArray[A]
}
@@ -357,6 +360,11 @@ private[compat] trait PackageShared { | |||
new RandomExtensions(self) | |||
} | |||
|
|||
class ArrayExtensions(private val fact: Array.type) extends AnyVal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final class?
7eaa94b
to
272af6e
Compare
Thank you! |
this has now shipped: https://github.com/scala/scala-collection-compat/releases/tag/v2.13.0 |
Without the extension, code fails to compile for scala 2.11 and 2.12 with
Add missing extension to the compat package