Created
July 25, 2020 09:14
-
-
Save gabrielstellini/b2f2a4607eb2dfed2309246c4916fbc3 to your computer and use it in GitHub Desktop.
Playing with types on dart
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() { | |
strongTypingExample(); | |
weakTypingExample(); | |
} | |
void printInts(List<int> a) => print(a); | |
void strongTypingExample() { | |
var list = <int>[]; // Removing <int> results in a type error | |
list.add(1); | |
list.add(2); | |
print(list); | |
} | |
void weakTypingExample() { | |
dynamic v = 123; | |
v = 456; | |
v = 'abc'; | |
print(v); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment