5
อาร์เรย์ใหม่จาก Index Range Swift
ฉันจะทำเรื่องแบบนี้ได้อย่างไร? นำ n องค์ประกอบแรกจากอาร์เรย์: newNumbers = numbers[0..n] ขณะนี้ได้รับข้อผิดพลาดต่อไปนี้: error: could not find an overload for 'subscript' that accepts the supplied arguments แก้ไข: นี่คือฟังก์ชันที่ฉันกำลังทำงานอยู่ func aFunction(numbers: Array<Int>, position: Int) -> Array<Int> { var newNumbers = numbers[0...position] return newNumbers }