Scala Programming Language
  1. Scala Programming Language
  2. SI-8081

unzip/unzip3 return wrong static type when applied to Arrays

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.3
    • Fix Version/s: Scala 2.11.0-RC1
    • Component/s: Collections
    • Labels:
      None

      Description

      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.

        Activity

        Show
        Adriaan Moors added a comment - https://github.com/scala/scala/pull/3320

          People

          • Assignee:
            Rex Kerr
            Reporter:
            Ben Wing
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development