Generic Operator

!=(_:_:)

Returns a Boolean value indicating whether the two given values are not equal. 2つの与えられた値が等しくないかどうかを指し示すブール値を返します。

Declaration 宣言

static func != <Other>(lhs: UInt8, rhs: Other) -> Bool where Other : BinaryInteger

Parameters パラメータ

lhs

An integer to compare. 比較する整数。

rhs

Another integer to compare. 比較するもう一方の整数。

Discussion 解説

You can check the inequality of instances of any BinaryInteger types using the not-equal-to operator (!=). For example, you can test whether the first UInt8 value in a string’s UTF-8 encoding is not equal to the first UInt32 value in its Unicode scalar view: あなたは、何らかのBinaryInteger型のインスタンスの不等性を不等演算子(!=)使って確認できます。例えば、あなたはある文字列のUTF-8符号化の中の最初のUInt8値が、それのユニコードスカラー値での最初のUInt32と等しくないかどうかを試験できます。


let gameName = "Red Light, Green Light"
if let firstUTF8 = gameName.utf8.first,
    let firstScalar = gameName.unicodeScalars.first?.value {
    print("First code values are different: \(firstUTF8 != firstScalar)")
}
// Prints "First code values are different: false"