- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Why does Tuple1.toString add a trailing comma?
Sat, 2009-08-08, 22:37
I noticed the following today:
scala> Tuple1("foo") res55: (java.lang.String,) = (foo,)
Why is there a trailing "," added? This appears to be deliberate: http://lampsvn.epfl.ch/trac/scala/changeset/9507
It's true for 2.7.X and 2.8. None of the other Tuples do this.
If this is actually a bug, I'll file a trac bug.
Thanks,Dean
scala> Tuple1("foo") res55: (java.lang.String,) = (foo,)
Why is there a trailing "," added? This appears to be deliberate: http://lampsvn.epfl.ch/trac/scala/changeset/9507
It's true for 2.7.X and 2.8. None of the other Tuples do this.
If this is actually a bug, I'll file a trac bug.
Thanks,Dean
Sun, 2009-08-09, 02:07
#2
Re: Why does Tuple1.toString add a trailing comma?
Ah, that would make sense, if inconvenient at times ;) Thx.
dean
On Sat, Aug 8, 2009 at 4:42 PM, Matt Fowles <matt.fowles@gmail.com> wrote:
dean
On Sat, Aug 8, 2009 at 4:42 PM, Matt Fowles <matt.fowles@gmail.com> wrote:
Dean~
This is probably to avoid ambiguity between 1 element tuples and parens used for precedence grouping. (1+2) is 3 while (1+2,) is list(3). Python does the same thing.
Matt
On Aug 8, 2009 5:36 PM, "Dean Wampler" <deanwampler@gmail.com> wrote:
I noticed the following today:
scala> Tuple1("foo") res55: (java.lang.String,) = (foo,)
Why is there a trailing "," added? This appears to be deliberate: http://lampsvn.epfl.ch/trac/scala/changeset/9507
It's true for 2.7.X and 2.8. None of the other Tuples do this.
If this is actually a bug, I'll file a trac bug.
Thanks,Dean
Dean~
This is probably to avoid ambiguity between 1 element tuples and parens used for precedence grouping. (1+2) is 3 while (1+2,) is list(3). Python does the same thing.
Matt