Label statements in the SWIFT switch statement

Source: Internet
Author: User

When we use a switch statement in traversal, we sometimes need to terminate the entire traversal rather than the switch statement, so the implementation of the label statement is necessary.

//Tags can be used to mark a loop body or switch code block, when using break or continue with this tag, you can control the label represents the object's terminal or execution, suitable for complex real control process/*requires that the loop be terminated directly when the exception data is encountered*/var score= [ the, the, +,101, the, -,-5, About]first: forSinchScore {//Define label first    Switchs/Ten{     Case Ten:        ContinueFirst//Using Labels     Case 9: println ("\ (s) divided into excellent")     Case 8: println ("\ (s) divided into good")     Case 8: println ("\ (s) divided into medium")     Case 0:         BreakFirst//use the label to terminate the For loop, if the label is not used here, the break will be Swit    default: println ("\ (s) divided into failed")    }}

Perhaps the code and language description of the advantages of abstraction, if not clear can be copied down with no label for a comparison

Label statements in the SWIFT switch statement

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.