Skip to content

Instantly share code, notes, and snippets.

@YBCS
Created October 31, 2019 16:12
Show Gist options
  • Save YBCS/8fc5e116456629f73ac77624456ca470 to your computer and use it in GitHub Desktop.
Save YBCS/8fc5e116456629f73ac77624456ca470 to your computer and use it in GitHub Desktop.
#6 codelabs --> Intro to Dart for Java devs!
// Impreratice code (not functional-style)
// String scream(int length) => "A${'a' * length}h!";
// main() {
// final values = [1, 2, 3, 5, 10, 50];
// for (var length in values) {
// print(scream(length));
// }
// }
// same code in functional style
String scream(int length) => "A${'a' * length}h!";
main() {
final values = [1, 2, 3, 5, 10, 50];
// 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