Created
May 25, 2020 15:15
-
-
Save lkannan/f0fba988c437f7334026ad361d15dcbb to your computer and use it in GitHub Desktop.
Demo for gist sharing of dart code ~π
³π
°ππ π π
π
°π
³π
΄π!
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
void main() { | |
//static typing | |
int a, b; | |
String x; //best practice | |
a = 10; x = 'foo'; | |
print ('$a $x'); //strong data type | |
//dynamic typing | |
var c,d; //use this sparingly, when the type of data is not known | |
c = 5; | |
d = 'bar'; | |
c = 'zoo'; | |
d = 11; | |
print('$c $d'); | |
//mixing both and creating confusion | |
var i = 1; //avoid this | |
print(i.runtimeType); | |
//i = 'hello'; | |
//how to initialize a value and still keep it dynamic | |
dynamic j = 1; | |
print(j.runtimeType); | |
j = 'hi'; | |
print(j.runtimeType); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment