|
Oktatás * Programozás 1 * Szkriptnyelvek Teaching * Programming 1 (BI) Félévek Linkek * kalendárium |
Nim2 /
case statementIn C it is called a Example 1let x = 3 case x of 1: echo "one" of 2: echo "two" of 3: echo "three" else: echo "something else" 𝥶At the end of the Example 2
𝥶You can also match multiple values as well as a range in a branch. Cover all casesA case statement must cover all possible cases. If the let x = 10 case x of 1: echo "one" of 2: echo "two" of 3: echo "three" else: discard The case expression
let x = 3 let status = case x of 1, 2: "one or two" of 3..5: "between three and five" else: "something else" echo status # between three and five |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |
||||