Reputation: 3749
This behavior seems to be broken (I am using Scala 2.9.1)
var b= new StringBuilder
These are OK:
b+='a'
b.append('b')
b.append("de")
This produces compile error:
b+="de"
Any idea as to why only StringBuilder#+=(c: Char) exists whereas both StringBuilder#append(c:Char) and StringBuilder#append(s:String) happily co-exist? What is wrong with declaring and implementing StringBuilder#+=(s: String)?
Is it oversight or some deeper problem in the Scala type system?
Upvotes: 10
Views: 10643
Reputation: 59994
Try b ++= "de"
. A String
is considered a collection of Char
s.
Upvotes: 25