Last active
April 27, 2022 17:08
-
-
Save AbdullohBahromjonov/0966a8fabc4b8bbfd4990c89884d660e to your computer and use it in GitHub Desktop.
Parsing one data type to another
This file contains hidden or 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
void main() { | |
//final one = int.parse('one'); //error | |
final two = double.parse('2.2'); //successful | |
final three = int.tryParse('one'); //null | |
final four = double.tryParse('4.5'); //successful | |
final one = int.parse('3'); | |
print(''' | |
$two | |
$three | |
$four | |
'''); | |
print(parsingInteger(one)); | |
} | |
int parsingInteger(Object n) { | |
return n as int; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment