Operators and Symbols

Operators

OperatorDescriptionBinary?Binding direction
+addyesleft
-1) subtract
2) negative (prefix)
yes
no
left
right
*multiplyyesleft
/divideyesleft
%moduloyesleft
**power/exponentiationyesright
>>right bit-shiftyesleft
<<left bit-shiftyesleft
&1) bit-wise AND
2) boolean AND
yesleft
|1) bit-wise OR
2) boolean OR
yesleft
^1) bit-wise XOR
2) boolean XOR
yesleft
=, +=, -=, *=, /=,
**=, %=, <<=, >>=, &=,
|=, ^=
assignmentsyesn/a
==equals toyesleft
!=not equals toyesleft
>greater thanyesleft
>=greater than or equals toyesleft
<less thanyesleft
<=less than or equals toyesleft
&&boolean AND (short-circuits)yesleft
||boolean OR (short-circuits)yesleft
??null-coalesce (short-circuits)yesleft
!boolean NOTnoright
[], ?[]indexingyesleft
., ?.1) property access
2) method call
yesleft
..exclusive rangeyesleft
..=inclusive rangeyesleft

Symbols and Patterns

SymbolNameDescription
_underscoredefault switch case
;semicolonstatement separator
,commalist separator
:colonobject map property value separator
::pathmodule path separator
#{}hash mapobject map literal
""double quotestring
``back-tickmulti-line literal string
''single quotecharacter
\1) escape
2) line continuation
escape character literal
()unitnull value
()parenthesesexpression grouping
{}bracesblock statement
||pipesclosure
[]bracketsarray literal
!bangfunction call in calling scope
=>double arrowswitch expression case separator
//commentline comment
///doc-commentline [doc-comment]
//!module docmodule documentation
/**/commentblock comment
/***/doc-commentblock [doc-comment]
(**)commentreserved
#!shebangreserved
++incrementreserved
--decrementreserved
...restreserved
~tildereserved
!.reserved
?questionreserved
#hashreserved
@atreserved
$dollarreserved
->arrowreserved
<-left arrowreserved
<|left trianglereserved
|>right trianglereserved
===strict equals toreserved
!==strict not equals toreserved
:=assignmentreserved
:;typo to ::reserved
::<>turbofishreserved