[Swift入門]英大文字、小文字変換のサンプル

2021年3月31日

書式
文字列.lowercased()
文字列.uppercased()

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
let strA = "STUDY SKILL"
let strB = "become smart"
let lowerRes = strA.lowercased()
let upperRes = strB.uppercased()
print("変換前の文字: \(strA) と \(strB)")
print("変換後の文字: \(lowerRes) と \(upperRes)")
let strA = "STUDY SKILL" let strB = "become smart" let lowerRes = strA.lowercased() let upperRes = strB.uppercased() print("変換前の文字: \(strA) と \(strB)") print("変換後の文字: \(lowerRes) と \(upperRes)")
let strA = "STUDY SKILL"
let strB = "become smart"
let lowerRes = strA.lowercased()    
let upperRes = strB.uppercased()    

print("変換前の文字: \(strA) と \(strB)")
print("変換後の文字: \(lowerRes) と \(upperRes)")

実行結果
$ swift test02.swift
変換前の文字: STUDY SKILL と become smart
変換後の文字: study skill と BECOME SMART

Swift

Posted by arkgame