Create array of strings using for-in in Swift

前端 未结 3 1794
谎友^
谎友^ 2021-01-14 05:54

I\'m learning Swift and found one wonderful tutorial where explained how to create card game. Point is that we use 14 cards with card images and image files are named ca

3条回答
  •  囚心锁ツ
    2021-01-14 06:58

    Using map() this could be written:

    var cardNamesArray = (0...13).map{"card\($0)"}
    

提交回复
热议问题