且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用迭代索引的Kotlin过滤器Lambda数组

更新时间:2023-11-26 20:00:52

filterIndexed函数完全适合这种情况:

filterIndexed function is suited exactly for this case:

array.filterIndexed { index, value -> index % n == 0 }