swift--methods for enumerating array elements

Source: Internet
Author: User

1Let array = ["Shenyang","Beijing", "Shanghai", "Guangzhou "]2 3 vari =04  forIinch 0.. Array.count5 {6Print"\ (i): {"+ Array[i] +"}")//Easy Output Array index7 }8 9 println ()Ten  forValueinchArray One { APrint"<"+ Value +">")//not easy to output array index - } -  the println () -  -  for(Index, value)inchEnumerate (Array)//global functions that assign indexes and values to index and value, respectively . - { +println"array index: \ (index) array element: \ (value)"  //This makes it easy to remove both the array index and the elements.  -}

swift--methods for enumerating array elements

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.