[Swift] hasSuffixでサフィックスを使うサンプル

書式
対象文字列.hasSuffix(文字列)

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
let cft = "https://arkgame.com"
print(cft.hasSuffix("COM"))
print(cft.hasSuffix("com"))
print(cft.hasSuffix("ark"))
print(cft.hasSuffix("Com"))
print(cft.uppercased().hasSuffix("Com".uppercased()))
let cft = "https://arkgame.com" print(cft.hasSuffix("COM")) print(cft.hasSuffix("com")) print(cft.hasSuffix("ark")) print(cft.hasSuffix("Com")) print(cft.uppercased().hasSuffix("Com".uppercased()))
let cft = "https://arkgame.com"

print(cft.hasSuffix("COM"))
print(cft.hasSuffix("com"))
print(cft.hasSuffix("ark"))
print(cft.hasSuffix("Com"))
print(cft.uppercased().hasSuffix("Com".uppercased()))

結果
false
true
false
false
true

Swift

Posted by arkgame