A useful tip I picked up was to use ii instead of j for an inner loop. It’s far more distinct than j.
If for some terrible reason you have even more inner loops you can easily continue the trend i, ii, iii, iiii, iiiii - or iv, v if you’re feeling roman
When you have multiple indices you’re also bound to have multiple cardinals those indices count up to, say foo.length and bar.length, so foo_i and bar_i are perfectly legible and self-documenting. A bit Hungarian but Hungarian is good in small amounts. Unless you’re dealing with width and height in which case it’s x and y but it’s not that width_i would be incomprehensible.
A useful tip I picked up was to use
ii
instead ofj
for an inner loop. It’s far more distinct thanj
.If for some terrible reason you have even more inner loops you can easily continue the trend
i
,ii
,iii
,iiii
,iiiii
- oriv
,v
if you’re feeling romanWhen you have multiple indices you’re also bound to have multiple cardinals those indices count up to, say
foo.length
andbar.length
, sofoo_i
andbar_i
are perfectly legible and self-documenting. A bit Hungarian but Hungarian is good in small amounts. Unless you’re dealing withwidth
andheight
in which case it’sx
andy
but it’s not thatwidth_i
would be incomprehensible.