-
Notifications
You must be signed in to change notification settings - Fork 81
Collections
Paolo Angeli edited this page Oct 13, 2019
·
6 revisions
Arrays can be explicitly casted to booleans accordingly to the .count property. If .count == 0 the cast is false, unless is true.
arr : [..] float; // define a variable lenght array
... // do something
is_empty := ! cast(bool) arr; // save a flag
Must be explicit so eg. you can't pass an array to a procedure that expects a boolean as an argument.
The cast is implicit if the array name is placed in an if
or in a while
conditional statement.
arr : [..] float; // define a variable lenght array
... // do something
if arr { // If the array now contains some values
... // Do something else
}
This is because if statements have a so-called "lacks conversion of bools" that checks for availability of an implicit type-safe defined boolean conversion.
These documents were verified using Grammarly free browser plugin for Chrome. Please use some spell checker before submitting new content.
- Variables and assignments
- Language data types
- Simple user-defined data types
- Expressions and operators
- Type-casting
- Pointers
- Declarations
- Arguments / Parameters
- Return values
- Overloading / Polymorhism
- Advanced features
- Lambdas
- Arrays
- Strings
- Composition of Structs
- Metaprogramming
- Templates / Generics