「Swift」uppercasedとlowercasedメソッドで文字列を大文字、小文字に変換するサンプル

書式
大文字変換
変数名.uppercased
小文字変換
変数名.lowercased
使用例

import Foundation

var cftA = "study swift"
var cftB:String = "in"
var cftC = "ARKGAME"
var cftD = "Com"

//文字列を大文字に変換
print("result1:  "  + cftA.uppercased)
print("result2:  "  + cftB.uppercased)

//文字列を小文字に変換
print("resul3:  "  + cftC.lowercased)
print("result4:  "  + cftD.lowercased)

実行結果
result1: STUDY SWIFT
result2: IN
resul3: arkgame
result4: com

Swift

Posted by arkgame