Last active
March 29, 2018 02:28
-
-
Save kmizu/23d6207f2dcf7da0bd0cebe24d6215cf to your computer and use it in GitHub Desktop.
Type inference of dartanalyzer is weak ?
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
[mizushima]$ dartanalyzer generics.dart | |
Analyzing generics.dart... | |
error • Missing parameter type for 'x' at generics.dart:13:37 • strong_mode_implicit_dynamic_parameter | |
1 error found. |
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
List<T> filter<T>(List<T> original, bool pred(T arg)) { | |
List<T> newList = []; | |
for(var e in original) { | |
if(pred(e)) { | |
newList.add(e); | |
} | |
} | |
return newList; | |
} | |
void main() { | |
var xs = filter<int>([1, 2, 3, 4, 5], (x) => x % 2 != 0); | |
var ys = filter([1, 2, 3, 4, 5], (x) => x % 2 != 0); | |
print(xs); | |
print(ys); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment