@Luvon@beehaw.org
link
fedilink
13
edit-2
1Y

I generally use a for each type loop or a map because I am usually applying some function across a collection, and in both cases I use the singular name from the collections plural.

’Cities.map(city -> …)’

For (val city in cities)

If I actually need the index for some reason I still prefer loop structures that give me the index and the item together

*note syntax pulled out of my head and not necessarily belonging to any specific language.

For ( city, index in cities)

cities.map((city, index) -> … )

If I need to double loop a matrix array I would use rowIndex and ColIndex for the indexes.

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 120 users / day
  • 257 users / week
  • 744 users / month
  • 3.72K users / 6 months
  • 1 subscriber
  • 1.48K Posts
  • 32.5K Comments
  • Modlog