- Installing
- Hello World
- Spaces
- Identation
- Basics
- Comments
- Output
- ++ method
- Assignments and types
- Operator Precedence
- String interpolation
- Input
- Simple arithmetic
- Multiline strings
- Assert
- Arrays and literal arrays
- Literal intervals
- If, for, while and repeat-until
- Message sends
- Conversion between basic type values
- Anonymous functions
- Evaluating an anonymous function
- Functions with method foreach
- Prototypes
- Packages
- Gradual typing
- Generic prototypes
- Important metaobjects
- The CyanInterpreter prototype
If, for, while and repeat-until
The syntax of the ‘if’ and ‘while’ statements are shown in this example:
Note that ( )
as not necessary for the ‘if’ and ‘while’ expressions but the { }
are mandatory.
Be aware that indentation must be respected when using these statements. See the Cyan manual for rules regarding the if statement. In particular, the } that closes a while statement should be either in the same line as keyword while or in the same column as it. There should be no semicolon after any } symbol.
There is a repeat-until statement that executes its statements until the until expression evaluates to true
For statement for can be used to iterate over any object that implements method iterator -> Iterator<T>
. Arrays and intervals implement it: