-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09cc774
commit 85d2173
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Dart Supports Underscore Digit Separators | ||
|
||
In Dart (starting from version 3.6.0), you can use underscores (`_`) as digit separators in number literals to make them more readable. This is especially handy for large numbers or when grouping digits for higher-level clarity. | ||
|
||
Here are some examples: | ||
|
||
```dart | ||
var n1 = 1_000_000; | ||
var n2 = 0.000_000_000_01; | ||
var n3 = 0x00_14_22_01_23_45; // MAC address | ||
var n4 = 65_1234_5678; // SG Phone number | ||
var n5 = 100__000_000__000_000; // one hundred million million! | ||
``` | ||
|
||
This feature makes it easier to read long numeric values and organize digits meaningfully. | ||
|
||
Dart isn’t alone in supporting this - other languages like JavaScript, Java, Python, and Kotlin also allow underscore digit separators. It's a great example of a feature that crosses language boundaries to make code cleaner and more human-readable. |