Last active
May 20, 2018 02:25
-
-
Save ezura/31606b48969a61ba3856fb0fa0620760 to your computer and use it in GitHub Desktop.
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() { | |
for (int i = 0; i < 5; i++) { | |
print('hello ${i + 1}'); | |
} | |
for (var i in ["1", false]) { | |
print(convertToBool(i)); | |
} | |
} | |
bool convertToBool(dynamic arg) { | |
print(arg.runtimeType); | |
if (arg is bool) return arg; | |
if (arg is String) return arg == 'true'; | |
// dynamic is like `NSObject`?? | |
return arg == 1; | |
// info: dead code | |
// -> checking control flow?? | |
throw new ArgumentError('Cannot convert $arg to a bool.'); | |
} | |
// bool convertToBool(int arg) { | |
// print(arg.runtimeType); | |
// return true; | |
// } | |
// bool convertToBool(String arg) { | |
// print(arg.runtimeType); | |
// return false; | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment