--- title: Control Flow description: If/else, while, for, c-style for, loop, match, break, continue, and return. icon: ArrowLeftRight --- ### If/Else ```mist if condition { // body } else if other_condition { // body } else { // body } ``` Used as an expression: ```mist let x = if true { 1 } else { 2 }; ``` ### While ```mist while condition { // body } ``` ### For ```mist for pattern in iterator { // body } for i in 0 .. 10 { // body } ``` ### C-Style For ```mist for (let mut i = 0; i < 10; i++) { // body } ``` ### Loop ```mist loop { // infinite loop } ``` ### Match ```mist match value { pattern1 => expr, pattern2 => { // block body } pattern3 | pattern4 => expr, } ``` ### Break / Continue ```mist break; continue; ``` ### Return ```mist return; return value; ```