dummy.cl: Update to include while expressions
This commit is contained in:
parent
b707bcef81
commit
d6a80e4961
14
dummy.cl
14
dummy.cl
@ -13,12 +13,20 @@ fn main() {
|
|||||||
x
|
x
|
||||||
};
|
};
|
||||||
|
|
||||||
// A `for` expression is like the for-else construct in Python, but it returns a value via the `break` keyword
|
// A `while` expression is like the while-else construct in Python,
|
||||||
let z = for i in 0..y {
|
// but it returns a value via the `break` keyword
|
||||||
|
let z = while false {
|
||||||
// do a thing repeatedly
|
// do a thing repeatedly
|
||||||
break true
|
break true
|
||||||
|
// If `while` does not `break`, fall through to the `else` expression
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
}
|
||||||
|
// The same is true of `for` expressions!
|
||||||
|
let w = for idx in 0..100 {
|
||||||
|
break idx
|
||||||
|
} else {
|
||||||
|
12345
|
||||||
|
}
|
||||||
// TODO: decide how to do IO
|
// TODO: decide how to do IO
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user