3 ms·
In there it says Lua uses 'for' for looping over integer ranges and object ranges. They didn't like that so they broke it up so that for is for integer ranges a
by stonemetal12 3y ago
In there it says Lua uses 'for' for looping over integer ranges and object ranges. They didn't like that so they broke it up so that for is for integer ranges and each is for object ranges.
That seems strange to me. A range is a range so why have different ways to iterate over ranges based on what type of range it is?
- giraffe_lady 3y agoI mean it is lua that has two different ways to loop, with different syntax and semantics, but calls them both "for." "Numeric for" and "generic for" are the official names, with separate pages in the docs. Having different names for them seems like a reasonable and not that surprising choice.
- xigoi 3y agoRanges are not a first-class object in Lua, the range-based for loop is basically a hardcoded special case.