Operator 演算子

+=(_:_:)

Adds two values and stores the result in the left-hand-side variable. 2つの値を加算して、結果を左手側の変数に格納します。

Declaration 宣言

static func += (lhs: inout UInt8, rhs: UInt8)

Parameters パラメータ

lhs

The first value to add. 加算する第1の値。

rhs

The second value to add. 加算する第2の値。

Discussion 解説

The sum of the two arguments must be representable in the arguments’ type. In the following example, the result of 21 + 120 is greater than the maximum representable Int8 value: 2つの引数の合計は、引数の持つ型において表現可能でなければなりません。以下の例において、21 + 120の結果は、最大限表現可能なInt8値より大きいです:


var x: Int8 = 21
x += 120
// Overflow error

Relationships 関係

From Protocol 由来プロトコル