Operators

Most of the PHP operators are present in THP.

Numbers

var number = 322
     ╰╴No statement matched
number + 1 number - 1 number * 1 number / 1 number % 2 number += 1 number -= 1 number *= 1 number /= 1 number %= 2
thp

There are no prefix/postfix increment operators (++, --), use += or -= instead.

// Use
 ╰╴No statement matched
number += 1 // instead of number++ // This is a compile error
thp

Comparison

These operators will not do implicit type conversion. They can only be used with same datatypes.

v1 < v2
╰╴No statement matched
v1 <= v2 v1 > v2 v1 >= v2
thp

There is only == and !=. They are equivalent to === and !==.

v1 == v2
╰╴No statement matched
v1 != v2
thp

Bitwise

TBD

number and 1
╰╴No statement matched
number or 2 number xor 1 number xand 1
thp

Strings

Strings do not use . for concatenation. They use ++.

"Hello " ++ "world."
╰╴No statement matched
thp

This new operator implicitly converts types to string

"Hello " ++ 322      // 322 will be converted to "322"
╰╴No statement matched
thp

Boolean

These operators work only with booleans, they do not perform type coercion.

c1 && c2
╰╴No statement matched
c1 || c2
thp

Ternary

There is no ternary operator. See Conditionals for alternatives.

Null

These are detailed in their section: Nullable types

val person = some_fun()
╰╴No statement matched
person?.name person?.name ?? "Jane" person?.greet?.() if person? { person.name }
thp