0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Basic Operators - Compound Assignment Operator

Posted at

Swift はいくつかの 複合代入演算子 compound assignment operators を備えている。
そのうちの1つ 加入代入演算子 addition assignment operator += がよく使われる。

var a = 1
a += 2
// これは a = a + 2 と同意で、a の値は 3 になる。
注意
加入代入演算子は値を返さない。そのため
let b = a += 2
はエラーになる。

そのほかの複合代入演算子については Swift Standard Library Operators Reference を参考にすること。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?