« Return to Thread: += and +

Re: += and +

by csar :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View in Thread



On Jan 10, 2008 12:16 PM, Eric Willigers <ewilligers@...> wrote:
What do we expect the following to print?

    var s = "A"
    s += "B" + "C"
    println(s)

ABC?

Do we expect the following to compile?

    false + "D"
    () + "E"

No, No?
Agree, this is what we see in other (statically typed) languages
 

It is nice to be able to write  println(n + " ...")
I agree that it is nice but this is why we have the strange effects above due to the globally available any2stringad
d - with infix constructors this could be done much cleaner 


I'll need to remember to use parens:  s += ("B" + "C")
This horrible as val  s = "B"+"C" works fine.


 « Return to Thread: += and +