Instance Method インスタンスメソッド

update(with:)

Inserts the given element into the set. 与えられた要素をセットへと挿入します。

Declaration 宣言

@discardableResult mutating func update(with newMember: AttributedString.FormattingOptions) -> AttributedString.FormattingOptions?

Return Value 戻り値

The intersection of [newMember] and the set if the intersection was nonempty; otherwise, nil. [newMember]とこの集合の交叉、その交叉が空でなかったならば;そうでなければ、nil

Discussion 議論

If newMember is not contained in the set but subsumes current members of the set, the subsumed members are returned. newMemberがこの集合の中に含まれないしかしこの集合の現在の要素を包含するならば、包含されたメンバが返されます。


var options: ShippingOptions = [.secondDay, .priority]
let replaced = options.update(with: .express)
print(replaced == .secondDay)
// Prints "true"

See Also 参照

Performing Set Operations 集合演算を実行する