Swift Notes 5

Source: Internet
Author: User

Definition of the array:

var Beijing line Line 10 = ["National Library", "BA Gou"]

Beijing Line Line 10. Count//or the length of the array

If Beijing line Line 10. IsEmpty {

println ("The array is empty");

}

Add a value to the array,

Beijing Line Line 10, append ("Agricultural exhibition Hall");

Beijing Line Line 10 + = ["Sun Palace", "Sanyuan Bridge", "Liang Qiao"]

Beijing Line Line 10 [0] = "Tuanjiehu"

Beijing Line Line 10. Insert ("Call Home", atindex:1)//Insert new value replace old value

To remove a value from an array

Beijing Line Line 10. Removeatindex (1)

Beijing Line Line 10. Removerlast ()//Remove Last

Iterating through an array

For station name in Beijing line Line 10 {

printf ("\ (station name)")

}

Sometimes we want to see the index value corresponding to each station name.

For (ordinal, station name) in enumerate (Beijing line Line 10) {

printf ("The Name of the" (ordinal) is: \ (station name) ")//String interpolation

}

Swift Notes 5

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.