📅  最后修改于: 2022-03-11 15:00:58.984000             🧑  作者: Mango
// the neatest way to get the first N elements of a Swift array is using
// prefix(_ maxLength: Int):
let someArray = [1, 2, 3, 4, 5, 6, 7]
let first5 = someArray.prefix(5) // 1, 2, 3, 4, 5