Skip to content

Expressions

Nat! edited this page Mar 1, 2023 · 3 revisions

Expressions are used in the following statements: if, for, set, while.

Method Call

You can use Objective-C [] method calls.

Array

You can specify an array of expressions with @() like @( 1, "A")

Number

You can use an integer number like 1,2,3 or floating point numbers like 0.1, 0.2, 0.3.

String

You can use strings like "foo" or @"foo".

Comparison

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

Example 1

{% if 1 < 2 %}
t
{% else %}
f
{% endif %}

Output:

t

Example 2

{% if 1 gt 2 %}
t
{% else %}
f
{% endif %}

Output:

f

Example 3

{% if 1 == 2 %}
t
{% else %}
f
{% endif %}

Output:

f

Example 4

{% if 1 ne 2 %}
t
{% else %}
f
{% endif %}

Output:

t

Example 5

{% if 1 == 1 ? NO : YES %}
t
{% else %}
f
{% endif %}

Output:

f

Clone this wiki locally