Array 的高階函式 filter, map and reduce.
這次要來跟大家介紹幾個在Swift 當中比較常用的陣列方法,不僅很神奇,而且可以大幅減少我們使用for迴圈的機會喔,對於整體的程式碼而言,也比較整潔,讓我們一起看看吧!
- Filter
假設今天有一個陣列如下
let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
These were the top 10 stories published by 彼得潘的 Swift iOS / Flutter App 開發教室 in September of 2017. You can also dive into daily archives for September of 2017 by using the calendar at the top of this page.