-
Notifications
You must be signed in to change notification settings - Fork 1
Expressions
Nat! edited this page Mar 1, 2023
·
3 revisions
Expressions are used in the following statements: if,
for, set,
while.
You can use Objective-C [] method calls.
You can specify an array of expressions with @() like @( 1, "A")
You can use an integer number like 1,2,3 or floating point numbers like 0.1, 0.2, 0.3.
You can use strings like "foo" or @"foo".
The available comparion operators are:
| Operator | Alternative Form | Descriptor |
|---|---|---|
eq |
'==' | Equality comparison |
ne |
'!=' | Inequality comparison |
lt |
'<' | Ascending comparison |
le |
'<=' | Ascending or equality comparison |
gt |
'>' | Descending comparison |
ge |
'>=' | Descending or equality comparison |
?: |
The ternary operator |
{% if 1 < 2 %}
t
{% else %}
f
{% endif %}
Output:
t
{% if 1 gt 2 %}
t
{% else %}
f
{% endif %}
Output:
f
{% if 1 == 2 %}
t
{% else %}
f
{% endif %}
Output:
f
{% if 1 ne 2 %}
t
{% else %}
f
{% endif %}
Output:
t
{% if 1 == 1 ? NO : YES %}
t
{% else %}
f
{% endif %}
Output:
f