Boolean Logic
The following set of functions all evaluate to true or false. They provide an alternate notation to using operators that may lend itself better when writing declarative code (e.g. when defining the fields of a declaration).
equals
Syntax
equals?($left or @left, $right or @right)
Description
This function checks whether both arguments are equals, it is equivalent to doing left == right.
Arguments
| Position | Possible Values | Required | Default Value |
|---|---|---|---|
| 1 | Resource collection -OR- Value | Yes | None |
| 2 | Resource collection -OR- Value | Yes | None |
Result
true or false.
Examples
$a = 1
$b = 2
$c = 1
equals?($a, $b) == false
equals?($a, $c) == true
switch
Syntax
switch($condition, @true_exp or $true_exp, @false_exp or $false_exp)
Description
This function evaluates the condition and returns either the true expression or false expression based on the value of $condition.
Arguments
| Position | Possible Values | Required | Default Value |
|---|---|---|---|
| 1 | Value | Yes | None |
| 2 | Resource collection -OR- Value | Yes | None |
| 3 | Resource collection -OR- Value | Yes | None |
Both true expression and false expression should be of the same type.
Result
true expression or false expression
Examples
$anything_but_null = "foobar"
$false_or_null = null
switch($anything_but_null, $var1, $var2) == $var1
switch($false_or_null, @ec2, @google) == @google
logic_and and logic_or
Syntax
logic_and($left, $right) and logic_or($left, $right)
Description
These functions apply the logical and or logical or operators respectively to their arguments. They are equivalent to $left && $right and $left || $right respectively.
Arguments
| Position | Possible Values | Required | Default Value |
|---|---|---|---|
| 1 | Value | Yes | None |
| 2 | Value | Yes | None |
Result
true or false.
Examples
$anything_but_null = "foobar"
$false_or_null = null
switch($anything_but_null, $var1, $var2) == $var1
switch($false_or_null, @ec2, @google) == @google
logic_not
Syntax
logic_not($value)
Description
Applies the logical not operator.
Arguments
| Position | Possible Values | Required | Default Value |
|---|---|---|---|
| 1 | Value | Yes | None |
Result
true or false.
Examples
logic_not(true) == false
logic_not(false) == true
$any_value_but_null = "foobar"
logic_not($any_value_but_null) == false
logic_not(null) == true