@@ -41,23 +41,22 @@ class Point {
41
41
42
42
## Operators
43
43
44
- Operators are instance methods with special names.
44
+ Most operators are instance methods with special names.
45
45
Dart allows you to define operators with the following names:
46
46
47
- | | | | |
48
- | ------| ------| ------| -------|
49
- | ` < ` | ` + ` | ` \| ` | ` >>> ` |
50
- | ` > ` | ` / ` | ` ^ ` | ` [] ` |
51
- | ` <= ` | ` ~/ ` | ` & ` | ` []= ` |
52
- | ` >= ` | ` * ` | ` << ` | ` ~ ` |
53
- | ` - ` | ` % ` | ` >> ` | ` == ` |
47
+ | | | | | | |
48
+ | -------| ------| ------| ------| -------| ------|
49
+ | ` < ` | ` > ` | ` <= ` | ` >= ` | ` == ` | ` ~ ` |
50
+ | ` - ` | ` + ` | ` / ` | ` ~/ ` | ` * ` | ` % ` |
51
+ | ` \| ` | ` ˆ ` | ` & ` | ` << ` | ` >>> ` | ` >> ` |
52
+ | ` []= ` | ` [] ` | | | | |
54
53
55
54
{:.table}
56
55
57
56
::: note
58
57
You may have noticed that some [ operators] [ ] , like ` != ` , aren't in
59
- the list of names. That's because they're just syntactic sugar. For example,
60
- the expression ` e1 != e2 ` is syntactic sugar for ` !(e1 == e2) ` .
58
+ the list of names. These operators aren't instance methods.
59
+ Their behavior is built in to Dart .
61
60
:::
62
61
63
62
{%- comment %}
@@ -66,9 +65,10 @@ the expression `e1 != e2` is syntactic sugar for `!(e1 == e2)`.
66
65
- ` ! ` is probably excluded for historical reasons
67
66
{% endcomment %}
68
67
69
- An operator declaration is identified using the built-in identifier ` operator ` .
70
- The following example defines vector
71
- addition (` + ` ), subtraction (` - ` ), and equality (` == ` ):
68
+ To declare an operator, use the built-in identifier
69
+ ` operator ` then the operator you are defining.
70
+ The following example defines vector addition (` + ` ), subtraction (` - ` ),
71
+ and equality (` == ` ):
72
72
73
73
<? code-excerpt "misc/lib/language_tour/classes/vector.dart"?>
74
74
``` dart
0 commit comments