-
Notifications
You must be signed in to change notification settings - Fork 1
/
operatorsandspecialsymbols.txt
69 lines (35 loc) · 1.72 KB
/
operatorsandspecialsymbols.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Kotlin supports the following operators and special symbols:
+, -, *, /, % - mathematical operators
* is also used to pass an array to a vararg parameter.
=
assignment operator.
is used to specify default values for parameters.
+=, -=, *=, /=, %= - augmented assignment operators.
++, -- - increment and decrement operators.
&&, ||, ! - logical 'and', 'or', 'not' operators (for bitwise operations, use the corresponding infix functions instead).
==, != - equality operators (translated to calls of equals() for non-primitive types).
===, !== - referential equality operators.
<, >, <=, >= - comparison operators (translated to calls of compareTo() for non-primitive types).
[, ] - indexed access operator (translated to calls of get and set).
!! asserts that an expression is non-null.
?. performs a safe call (calls a method or accesses a property if the receiver is non-null).
?: takes the right-hand value if the left-hand value is null (the elvis operator).
:: creates a member reference or a class reference.
.. creates a range.
: separates a name from a type in a declaration.
? marks a type as nullable.
->
separates the parameters and body of a lambda expression.
separates the parameters and return type declaration in a function type.
separates the condition and body of a when expression branch.
@
introduces an annotation.
introduces or references a loop label.
introduces or references a lambda label.
references a 'this' expression from an outer scope.
references an outer superclass.
; separates multiple statements on the same line.
$ references a variable or expression in a string template.
_
substitutes an unused parameter in a lambda expression.
substitutes an unused parameter in a destructuring declaration.