快速访问数组中的奇偶元素

时间:2018-08-01 16:31:10

标签: arrays swift xcode

想知道,如何在Swift中按奇/偶/奇/偶排序数组? 请参见下面的示例:

let exampleArray = ["a", "b", "c", "d", "e", "f"]

let oddExampleArray = exampleArray[???PLEASE HELP??] // Would Print "a", "c", "e"
let evenExampleArray= exampleArray[???PLEASE HELP???] // Would Print "b", "d", "f"

0 个答案:

没有答案