Iterate through alphabet in Swift

前端 未结 8 1940
暗喜
暗喜 2020-12-30 02:23

in Obj-C it was possible to iterate through alphabet with:

for (char x=\'A\'; x<=\'Z\'; x++) {

In Swift this isn\'t possible. Any idea h

8条回答
  •  半阙折子戏
    2020-12-30 02:43

    Swift 4.2 version is much easier

    for char in "abcdefghijklmnopqrstuvwxyz" {
        print(char)
    }
    

提交回复
热议问题