Is there a function that I can use to repeat on an array and like both the pointer and the element, Like calculating python?
"Text">
Yes as swift 3.0, if you need an index for each element with its value, you can use it to be repeated on the array. It gives a tube made of index and gives value to each item in the array. For example:
for (index, element) list.enumerated () {print ("item \ (index): \ (element)")}
Swift 3.0 and Swift 2.0, the function enumerate ()
: for (index, element) list.enumerate () {print (" Item \ (index): \ (element) ")}
Before Swift 2.0, enumerate
was a global function. Calculate (list) {println ("item \ (index): \ (element)")
>
Comments
Post a Comment