Skip to content

Instantly share code, notes, and snippets.

@CaiJingLong
Last active March 10, 2020 03:02
Show Gist options
  • Save CaiJingLong/9fad35845c0ccc0752580baafac1bb48 to your computer and use it in GitHub Desktop.
Save CaiJingLong/9fad35845c0ccc0752580baafac1bb48 to your computer and use it in GitHub Desktop.
range like python for dart
void main() {
print(range(100, start: 1, step: 7));
}
Iterable<int> range(int end, {int start = 0, int step = 1}) sync* {
assert(step >= 1);
int r = start;
while (r < end) {
yield r;
r += step;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment