Skip to content

Instantly share code, notes, and snippets.

@gabrc52
Created January 19, 2019 20:31
Show Gist options
  • Save gabrc52/0e5a3ff7daff4be34a415bc0d6494ecc to your computer and use it in GitHub Desktop.
Save gabrc52/0e5a3ff7daff4be34a415bc0d6494ecc to your computer and use it in GitHub Desktop.
Python-like range function in Dart
Iterable<int> range(int start, [int stop, int increment]) sync* {
if (increment == null) {
increment = 1;
}
if (stop == null) {
stop = start;
start = 0;
}
for (int i = start; start < stop ? i < stop : i > stop; i += increment) {
yield i;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment