1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Swiftで大文字か小文字か判定する&アルファベットが格納された配列

Last updated at Posted at 2020-07-10

CharacterのisUppercaseプロパティは大文字かどうかを、isLowercaseは小文字かどうかを判定してくれます。

let a:Character = "a"//Character(readLine()!)
if a.isUppercase {
    print("小文字です")
} else {
    print("大文字です")
}

["a","b","c"..."z"]["A","B","C"..."Z"]は使えそう
参考

let upChaAry = (65...90).map{ String(Character(UnicodeScalar($0)!)) }
let lowChaArr = (97...122).map{String(Character(UnicodeScalar($0)!))}
print(lowChaArr)
print(upChaAry)
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?