6 ms·
`for` is a foreach. If you want to increment a number through a range like a typical C `for`, you have to use a `while` loop. I don't really see the draw.
by firethief 5y ago
`for` is a foreach. If you want to increment a number through a range like a typical C `for`, you have to use a `while` loop. I don't really see the draw.
- dnautics 5y agoman if I were andrew I'd just rename for to "foreach", because this is a huge complaint and source of confusion.
- kzrdude 5y agoSeems fine to me. Rust has a "foreach" which is named for, working ok. Of course Rust has ranges as iterators, so it's not necessarily noticed that "there is no numerical for" but it works.
- masklinn 5y ago> Rust has a "foreach" which is named for, working ok. Also ruby / python. Don't see the point of a C-style for loop in a modern language, reusing the keyword is perfectly sensible (even more so as many which have both use the same keyword). C# actively weirds me out every time from having both for and foreach, complete waste of brainspace.
- anonymoushn 5y agoIt seems fine to just delete it if it's only ever going to work on slices and arrays