Filter array by indices

前端 未结 3 1271
闹比i
闹比i 2020-12-06 07:38

I have an array of elements. I also have an IndexSet that specifies which indices of the array need to be extracted into a new array. E.g.:

let array = [\"su         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 08:23

    You can use Array.elements(at:)

    let result = array.elements(at: indexSet)
    

提交回复
热议问题