「Swift5」isEmpty メソッドで空文字を判定する

環境
Swift version 5.2.3 (swift-5.2.3-RELEASE)

書式
let 変数名 =値
変数名.isEmpty
isEmpty メソッドを使用して、空文字を判定します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
let strA = ""
print(strA.isEmpty)
let strB = "study skill"
print(strB.isEmpty)
let strA = "" print(strA.isEmpty) let strB = "study skill" print(strB.isEmpty)
let strA = ""
 
print(strA.isEmpty)
 
let strB = "study skill"
 
print(strB.isEmpty)

結果
true
false

Swift

Posted by arkgame