Increment (++) operator in Scala
问题 Is there any reason for Scala not support the ++ operator to increment primitive types by default? For example, you can not write: var i=0 i++ Thanks 回答1: My guess is this was omitted because it would only work for mutable variables, and it would not make sense for immutable values. Perhaps it was decided that the ++ operator doesn't scream assignment, so including it may lead to mistakes with regard to whether or not you are mutating the variable. I feel that something like this is safe to