Skip to content

Instantly share code, notes, and snippets.

@lkannan
Created May 25, 2020 15:15
Show Gist options
  • Save lkannan/f0fba988c437f7334026ad361d15dcbb to your computer and use it in GitHub Desktop.
Save lkannan/f0fba988c437f7334026ad361d15dcbb to your computer and use it in GitHub Desktop.
Demo for gist sharing of dart code ~πŸ…³πŸ…°πŸ†πŸ†ƒ πŸ’€ πŸ†…πŸ…°πŸ…³πŸ…΄πŸ†!
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