4Blocks are collections of statements wrapped in braces `{ ... }`. Blocks must return a value of the same type on every branch of execution.
6The following types of statement are supported:
12- If-Then-Else statements
14Here is an example of a power function defined using a block::
18 for (i <- 0 until p) {
24Blocks enable local mutation of their variables, but mutation is not allowed in general. The type system prevents mutable variables from escaping their scope.
26That is, while the example above is valid, the following does not compile::
33The variable `n` is not mutable, and so the assignment in the first line of the `do` block is not allowed.
35This function can be rewritten as follows::
46For loops iterate over a range of numbers::
50 for (i <- 0 until 10) {
56The bounds `0` and `10` are inclusive and exclusive respectively.
61While loops repeat a set of statements while a boolean expression evaluates to `true`::
73If-Then-Else Statements
74-----------------------
76Else branches are optional, and may contain further `if` statements, just as in Javascript:
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list