the common notation 'for k,v in table do' is used because it's easy to read/recognize.
Whenever you use the 'generic' form of the for statement on a table WITHOUT an iterator (i.e. 'for k,v in table' vs. for 'k,v in pairs(table)' ), the for statement automatically provides 2 variables for each run through the loop - the key and it's associated value - thus k and v. When we (teachers?) give helpful examples, we commonly use k,v to emphisize the key and the value inside the sample.
yes, 'for k,v...' works on every table.
|