Re: Seq :+ repeat parameter
Oliver Ruebenacker <[email protected]> Thu, 7 Apr 2016 10:10:26 -0400
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <CAA=X4ODvo5gzNi2ZjcnQzzATPvfhhH56QNYPipSHond3CzFNBg@mail.gmail.com> |
Hello,
I'm not sure that Paul Philips was too concerned about that aspect of
type inference.
These typical code bugs that lead to references inferred as Any, AnyRef,
AnyVal or Nothing are usually quite harmless: as soon as you are trying to
use the reference you notice that you can't do much with it and realize
quickly what is going on.
Union types: I would assume if you have a union type A|B, you cannot call
A's methods on it, but you would have to match A first. In that case, I
don't see much change.
Best, Oliver
On Thu, Apr 7, 2016 at 9:29 AM, Rich Oliver <[email protected]> wrote:
> On Thursday, 7 April 2016 13:49:18 UTC+1, Oliver Ruebenacker wrote:
>>
>>
>> Hello,
>>
>> Is it possible that your code does not do what one might think it does?
>>
>> scala> val seq = Seq(1, 2, 3)
>> seq: Seq[Int] = List(1, 2, 3)
>>
>> scala> val seq2 = seq :+ (4, 5, 6)
>> seq2: Seq[Any] = List(1, 2, 3, (4,5,6))
>>
>> Best, Oliver
>>
>
> Hi yes you're right. I was forgetting Scala's insanely hyperactive type
> inference. Well at least I'm not alone, it drove Paul Phillips to despair.
> Will this madness get worse with type unions?
>
> --
> 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.
>
--
Oliver Ruebenacker
Senior Software Engineer, Diabetes Portal
<http://www.type2diabetesgenetics.org/>, Broad Institute
<http://www.broadinstitute.org/>
--
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.