Reused Variables in Go

In general it’s a bad idea to reuse/recycle variables (see: Software Design/Don’t reuse a variable). It makes code less readable, debugging more difficult, and can lead to bad designs.

range

range is a Go built-in keyword provided to iterate over arrays and slices. The syntax is shorter than C-style for loops ForStmt = "for" [ Condition | ForClause | RangeClause ] Block ., but the way it works may be confusing at first.

Austin Millan

Software engineer at APCON, Inc.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store