Skip to content

Instantly share code, notes, and snippets.

@eltray
Created August 2, 2019 09:07
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 eltray/18fcd1ec25832124a56b00f53bbe00ab to your computer and use it in GitHub Desktop.
Save eltray/18fcd1ec25832124a56b00f53bbe00ab to your computer and use it in GitHub Desktop.
Learning Dart - 6. Use Dart for functional programming
String scream(int length) => "A${"a" * length}h!";
main() {
var values = [1, 2, 3, 4, 10];
// Imperative way
// for (int length in values){
// print(scream(length));
// }
// Functional way
// values.map(scream).forEach(print);
values.skip(1).take(3).map(scream).forEach(print);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment