Open
Description
In Dart code, I see code with the following structure very often:
for (var i = 0; i < 10; i++) {
print('Hello world');
}
This is a very imperative way of programming (first, setting i
to 0
, then checking if i < 10
and after each iteration increasing i
by one).
Most people try to code in a higher-level declarative way and I thought it's weird that the Dart core SDK doesn't have something like a Range
that could be created with a to
extension method on int
so that you could simply do
for (final i in 0.to(10)) {
print('Hello world');
}
Sure, there are third-party packages that offer this functionality, but this is such a fundamental, basic functionality that I believe it's common enough to be in the standard library. I'm looking forward seeing this being integrated into the platform.