3 ms·
I've programmed in dozens of languages, and I can't think of another one where loops could automatically run either up or down depending on the start and end va
by Stratoscope 15y ago
I've programmed in dozens of languages, and I can't think of another one where loops could automatically run either up or down depending on the start and end values.
Not knowing CoffeeScript well, when I see this code:
n = -10
for i in [0...n]
doSomething()
I'd expect it to call doSomething zero times. At least that's what I'd expect in JavaScript or any of the other languages I've used.
- jashkenas 15y agoI agree with you at least 40%, and that's originally how CoffeeScript behaved. Would you still feel that way if you had explicitly written: for i in [10..0] I've opened a ticket to discuss this further: https://github.com/jashkenas/coffee-script/issues/1952 https://github.com/jashkenas/coffee-script/issues/1952