The difference between OC and Swift four

Source: Internet
Author: User

12. The difference between conditional statements, where only the difference is written here, does not point out the difference in other respects OC is basically consistent with Swift

12.1

For if switch statement body in OC If there is only one line of code, {} can omit

The body of the for if switch statement in Swift must use {}, otherwise there is a syntax error

Differences in 12.2for-in syntax:

Cycle from 1 to 3, including 3, i.e. 3 cycles

For I in 1..3{

}

If you do not need to use a value in the loop condition range, use _ to ignore the loop condition value so that it does not create a local variable in the loop body

For _ in 1..3{

}

The cyclic condition value is constant and cannot be changed in the loop body

For I in 1...3{

i = 10//This code error

}

The difference between OC and Swift four

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.