Why does the following compile?
scala> val ch1 = 'a' + 'b'
ch1: Int = 195
but the following doesn't?
scala> var ch1 = 'a'
ch1: Char = a
scala> ch1 += 'b'
<console>:9: error: type mismatch;
found : Int
required: Char
ch1 += 'b'
^
scala> ch1 = ch1 + 'b'
<console>:8: error: type mismatch;
found : Int
required: Char
ch1 = ch1 + 'b'
^
And why is the error message so misleading? Why does it say required: Char
when what I am passing is clearly a Char
?