fasterthanlime / feedback

An issue tracker for articles/series/videos at https://fasterthanli.me/
13 stars 0 forks source link

Go 1.22 Update #301

Open DavidArchibald opened 6 months ago

DavidArchibald commented 6 months ago

This is a nitpick/minor update but in the "Abstracting away correctness" article it claims that for i := 0; i < 4; i++ can't be written any other way but as of Go 1.22 this isn't true anymore. for i := range 4 would be the blessed way of doing it now which even the StackOverflow answer you linked to while saying "no, why would you ask" now acknowledges.

Obviously at date of writing this was true but now, 4 years later, Go has finally given the tiniest bit of syntax sugar. Not that it actually lets you range over just any iterator yet so I haven't even found a use for it once yet... (since I'm always ranging over arrays/maps)