Operator precedence

The following list orders the Gosu operators from highest to lowest precedence. Gosu evaluates operators with the same precedence from left to right. The use of parentheses can modify the evaluation order as determined by operator precedence. Gosu first evaluates an expression within parentheses, then uses that value in evaluating the remainder of the expression.

Operator

Description

.

[ ]

( )

?.

?[]

Property access, array indexing, function calls and expression grouping. The operators with the question marks are the null-safe operators.

new

Object creation, object reflection.

,

Array value list, as in {value1, value2, value3}

Argument list, as in (parameter1parameter2parameter3)

as

Casting a value to a specific type.

+

-

Unary operands for positive value and negative value.

~

!

not

typeof

eval

Bit-wise OR, logical NOT, type of, eval(expression).

typeis

Determine if an object is a specific type or subtype.

*

/

%

Multiplication, division, modulo division.

<<

>>

>>>

Bitwise shifting.

+

-

?+

?-

Addition, subtraction, string concatenation. The versions with the question marks are the null-safe versions.

<

<=

>

>=

Less than, less than or equal, greater than, greater than or equal

==

===

!=

!==

Equality and inequality operators for values and references.

&

Bitwise AND.

^

Bitwise exclusive OR.

|

Bitwise inclusive OR.

&&

and

Logical AND. The two variants are equivalent.

||

or

Logical OR. The two variants are equivalent.

?  :

?:

Ternary conditional. For example: 3*3 == 9 ? true : false

Null-safe default operator

= += -= *= /= %= &= &&= ^= |= ||= <<= >>= >>>=

Assignment operator statements. These operators apply to Gosu statements, not expressions.

See also