Skip to content

Instantly share code, notes, and snippets.

@passsy
Last active May 13, 2019 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save passsy/bab95e3320cb9abbbb08282210c07ca4 to your computer and use it in GitHub Desktop.
Save passsy/bab95e3320cb9abbbb08282210c07ca4 to your computer and use it in GitHub Desktop.
Missing compile time check
class Apple {}
class Banana {}
List<Apple> bag([List<Apple> apples]) => apples ?? <Banana>[];
void main() {
// ok
final bag1 = bag([Apple()]);
print(bag1);
// throws runtime error, should be compile time error
final bag2 = bag();
print(bag2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment