|
|
|
|
|
by nextaccountic
141 days ago
|
|
Just do for counter in <1, 5>.rev(), which would iterate in a reversed range. IMO it's poinless to distinguish synctactically between iterating forwards and backwards, specially if you also support things like for counter in <1, 5>.map({ return args[1] * 2) to irate on even numbers (the double of each number), rather than having to define a fordoubled macro. I mean, adding method like map and rev to ranges is more orthogonal and composes better. (See for example iterators in Rust) Not that I don't like syntactic flexibility. I am a big fan of Ruby's unless, for example |
|
I think what you’re suggesting would require the <a, b> syntax to produce a proper iterator type, which it doesn’t currently do. That’s definitely worth considering — then you could attach methods, etc.
Thanks for the suggestion! I’ll think about the best way to fix this..