Seventh lesson fourth, T language Process statement (version 5.0)

Source: Internet
Author: User
Tags terminates
Break statement

Typically used in loops, traversal statements. When a break statement is used in a looping statement, the program terminates the loop and executes the statement following the loop, usually jumping out of a statement that is always associated with a statement if the condition is met. You can say: jump out of the statement is the bane of the loop process, as long as the execution of the jump statement, The loop process terminates immediately.

(keyword, break)

Attention:

1, can only be executed in the while and for statements, execution out of the statement break the entire loop

2. Executing a break statement can only interrupt the loop body of the layer closest to the jump statement

Example:

1. Single-loop use of jump-out statements

var i=0 while (true)  //Set Loop    if (i==27) break      //Judge meet condition to jump out while    

  

When the condition of the statement "if(i==27)" is established, a jump statement is executed, which interrupts the while statement to continue execution, thus ending the while statement.

2. Use the jump statement in case of nested loops.
while (true) for   (var i=0;i<100;i++)     if (i = =)       break//only jumps out of the For loop body     End   

  

A jump statement is executed when the condition of the statement "if (i = = 50)" is true. According to note 2 We know that the jump statement only interrupts the for statement to continue execution, but does not affect the execution of the loop statement.

Seventh lesson fourth, T language Process statement (version 5.0)

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.