Re: Unexpected productIterator order
Simon Schäfer <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <[email protected]> |
On 03/19/2015 06:15 PM, Simon Adameit wrote:
> Hello,
>
> we noticed some strange behaviour of productIterator in Scala 2.11.5:
>
> case class Data(a: String, b: String, `a-some`: String)
> val m = Data("1", "2", "3")
> assert(m.productIterator.mkString(", ") == "1, 2, 3")
>
> Result: "1, [3, 2]" did not equal "1, [2, 3]"
>
> "a-some" can be any mangled symbol with an "a" prefix.
>
> Is the order of productIterator on case classes guaranteed to be in
> parameter order? If so, this seems to be a bug. Can anyone reproduce it?
Product.productElement
(http://scala-lang.org/api/current/index.html#scala.Product@productElement%28n:Int%29:Any)
says:
The n^th element of this product, 0-based. In other words, for a product
|A(x_1 , ..., x_k )|, returns |x_(n+1) | where |0 < n < k|.
Therefore, it is a bug in productElement. However, productIterator
doesn't specify ordering...
>
> Regards,
> Simon Adameit
> --
> You received this message because you are subscribed to the Google
> Groups "scala-language" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.