after using the prefix method on an Array I get what is called an arraySlice. How can I transform this into an Array?
I am trying to fetch Ints from FacebookGraphApi then asking for the first 3 (prefix(3)) and trying to add them into a new array.
Thank you in advance
The ArraySlice type makes it fast and efficient for you to perform operations on sections of a larger array. Instead of copying over the elements of a slice to new storage, an ArraySlice instance presents a view onto the storage of a larger array.
first(where:) Returns the first element of the sequence that satisfies the given predicate.
Just initialize a new Array
with the slice:
let arr1 = [0,1,2,3,4,5,6,7] let slice = arr1[2...5] let arr2 = Array(slice)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With