Created
August 16, 2020 20:16
-
-
Save Alkimisti/e9add9f6daae76c58a911d29bf417a77 to your computer and use it in GitHub Desktop.
Conversion int, String, double
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
// Conversions int <-> String, double <-> String | |
void main() { | |
// Convert String to double | |
var s = '12.95'; | |
var d = double.parse(s); | |
print('${d.runtimeType} $d'); | |
// Convert double to String | |
d = 12.95; | |
s = d.toString(); | |
print('${s.runtimeType} $s'); | |
// Convert String to int | |
s = '13'; | |
var i = int.parse(s); | |
print('${i.runtimeType} $i'); | |
// Convert int to String | |
i = 13; | |
s = i.toString(); | |
print('${s.runtimeType} $s'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment