3 ms·
'datum' often is a more appropriate name. 'data' is ambiguous w.r.t singular/plural. However, I prefer 'item' and 'items', as that completely evades any possib
by Someone 15y ago
'datum' often is a more appropriate name. 'data' is ambiguous w.r.t singular/plural.
However, I prefer 'item' and 'items', as that completely evades any possible confusion. Especially useful when iterating over generic containers. Compare:
Foreac
- Someone 15y agoOops, hit the "reply" button by accident when trying to dismiss a spelling correction on the iPad, and I do not know how to edit, due to my anti-procrastination setting. Intended was to compare: Foreach item in items With Foreach datum in data I also use itemss for a container of containers: Foreach items in itemss Foreach item in items Of course, if the code is less generic, different names are more appropriate: Foreach row in matrix Foreach cell in row
- AncientPC 15y agoFor small scoped loops, I usually just abbreviate to the first letter. I'm not sure how others feel about this, but I think it's perfectly legible: for i in items: i += 1 for r in rows: for c in columns: matrix[r][c] *= 2