Skip to content
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

unzip/unzip3 return wrong static type when applied to Arrays #8081

Closed
scabug opened this issue Dec 15, 2013 · 2 comments
Closed

unzip/unzip3 return wrong static type when applied to Arrays #8081

scabug opened this issue Dec 15, 2013 · 2 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Dec 15, 2013

When unzip() and unzip3() are applied to an Array, they return something of type IndexedSeq instead of Array. Various other functions (e.g. sortBy(), transpose()) do the right thing on arrays.

scala> val x = Array(Array(3,6),Array(4,7),Array(5,8))
x: Array[Array[Int]] = Array(Array(3, 6), Array(4, 7), Array(5, 8))

scala> x.transpose
res0: Array[Array[Int]] = Array(Array(3, 4, 5), Array(6, 7, 8))

scala> val x = Array((5,Array(1.2,2.5)), (6,Array(3.4,6.7)))
x: Array[(Int, Array[Double])] = Array((5,Array(1.2, 2.5)), (6,Array(3.4, 6.7)))

scala> x.unzip
res1: (scala.collection.mutable.IndexedSeq[Int], scala.collection.mutable.IndexedSeq[Array[Double]]) = (ArrayBuffer(5, 6),ArrayBuffer(Array(1.2, 2.5), Array(3.4, 6.7)))

scala> val x = Array(("foo",5,Array(1.2,2.5)), ("bar",6,Array(3.4,6.7)))
x: Array[(String, Int, Array[Double])] = Array((foo,5,Array(1.2, 2.5)), (bar,6,Array(3.4, 6.7)))

scala> x.unzip3
res2: (scala.collection.mutable.IndexedSeq[String], scala.collection.mutable.IndexedSeq[Int], scala.collection.mutable.IndexedSeq[Array[Double]]) = (ArrayBuffer(foo, bar),ArrayBuffer(5, 6),ArrayBuffer(Array(1.2, 2.5), Array(3.4, 6.7)))

This hasn't changed in the latest Scala 2.11 code.

@scabug
Copy link
Author

@scabug scabug commented Dec 15, 2013

Imported From: https://issues.scala-lang.org/browse/SI-8081?orig=1
Reporter: Ben Wing (benwing)
Affected Versions: 2.10.3

@scabug scabug closed this Jan 15, 2014
@scabug
Copy link
Author

@scabug scabug commented Jan 15, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants