@@ -159,7 +159,7 @@ assert((3 & 4) == 0); // 0011 & 0100 == 0000
159
159
For more examples, see the
160
160
[ bitwise and shift operator] [ ] section.
161
161
162
- Literal numbers are compile-time constants.
162
+ Number literals are compile-time constants.
163
163
Many arithmetic expressions are also compile-time constants,
164
164
as long as their operands are
165
165
compile-time constants that evaluate to numbers.
@@ -173,6 +173,26 @@ const msUntilRetry = secondsUntilRetry * msPerSecond;
173
173
174
174
For more information, see [ Numbers in Dart] [ dart-numbers ] .
175
175
176
+ You can use one or more underscores (` _ ` ) as digit separators
177
+ to make long number literals more readable.
178
+ Multiple digit separators allow for higher level grouping.
179
+
180
+ {% comment %}
181
+ Attach code excerpt misc/lib/language_tour/built_in_types.dart (digit-separators)
182
+ when feature is stable:
183
+ {% endcomment %}
184
+
185
+ ``` dart
186
+ var n1 = 1_000_000;
187
+ var n2 = 0.000_000_000_01;
188
+ var n3 = 0x00_14_22_01_23_45; // MAC address
189
+ var n4 = 555_123_4567; // US Phone number
190
+ var n5 = 100__000_000__000_000; // one hundred million million!
191
+ ```
192
+
193
+ ::: version-note
194
+ Using digit separators requires a [ language version] [ ] of at least 3.6.0.
195
+ :::
176
196
177
197
## Strings
178
198
@@ -254,7 +274,7 @@ var s = r'In a raw string, not even \n gets special treatment.';
254
274
See [ Runes and grapheme clusters] ( #runes-and-grapheme-clusters ) for details on how
255
275
to express Unicode characters in a string.
256
276
257
- Literal strings are compile-time constants,
277
+ String literals are compile-time constants,
258
278
as long as any interpolated expression is a compile-time constant
259
279
that evaluates to null or a numeric, string, or boolean value.
260
280
@@ -415,3 +435,4 @@ Symbol literals are compile-time constants.
415
435
[ characters API ] : {{site.pub-api}}/characters
416
436
[ characters example ] : {{site.pub-pkg}}/characters/example
417
437
[ `Symbol` ] : {{site.dart-api}}/{{site.sdkInfo.channel}}/dart-core/Symbol-class.html
438
+ [ language version ] : /guides/language/evolution#language-versioning
0 commit comments