爲什麼下面編譯?誤導性的編譯時錯誤
scala> val ch1 = 'a' + 'b'
ch1: Int = 195
但是下面不是嗎?
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'
^
爲什麼錯誤信息如此令人誤解?爲什麼它說required: Char
當我通過顯然是Char
?