- 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
Assert
In Cyan, we have a simple method to check the validity of an evaluated expression. Macro assert
generates code that checks at runtime whether its argument is true. It issues a warning if it is not.
assert 1 – 1 == 0; // ok
assert 0 == 1; // runtime error
assert 0 == 1; // runtime error
In resume, assert is a macro for testing an expression and can be used along with any type or literal
assert Person getName == “Marcia”;
assert Int*Int + Int == 0;
assert Int*Int + Int == 0;
Even with Java types
var java.lang.Integer integer = Integer(5);
assert 5 == integer;
assert 5 == integer;