Scala Tutorialsを読む 28 Immutable collections with var

http://scalatutorials.com/tour/interactive_tour_of_scala_immutable_collections_with_var.html

28 Immutable collections with var

28 varでのイムータブルコレクション

One thing to note is the difference between the +=, +==, -=, -== etc functions regarding mutable and immutable collections.

1つ注意すべき点は+=,+==,-=,-==等の関数のmutableとimmutableコレクションの違いです。

  • For immutable collections - they are not methods of the collection (since it's not modifiable) but if used on an immutable collection declared with var instead of val then the Scala compiler expands them to variable = variable op param. (see on the left for an example)

  • イムータブルなコレクションでは - これらのメソッドはコレクションにありませんが、もしもimmutableコレクションをvalではなくvarを使って宣言した場合はScalaコンパイラはvariable = variable op 引数に展開します。(左の例を見てください)

  • For mutable collections - they are actually methods on the collection, and they modify the collection when used.

  • ムータぶるなコレクションでは - これらのメソッドを持っており、使用した場合はコレクションは更新されます。