TheWisest
|
  |
| Joined: 11 Nov 2010 |
| Total Posts: 7345 |
|
|
| 02 Oct 2011 11:24 AM |
I don't just mean 'for i,v in pairs', because I have seen 'i,b in pairs', 'i,c in pairs' ect...
So what exactly does this function do, and how can I apply it? |
|
|
| Report Abuse |
|
|
acealeam
|
  |
| Joined: 16 Oct 2009 |
| Total Posts: 14875 |
|
|
| 02 Oct 2011 11:26 AM |
It's all the same. It's just different variables. People tend to use for i, v more because I is Interval and V is value.
~One day your life will flash before your eyes, make sure it's worth watching.~ |
|
|
| Report Abuse |
|
|
Lowcart
|
  |
| Joined: 12 Sep 2011 |
| Total Posts: 1323 |
|
| |
|
Varp
|
  |
| Joined: 18 Nov 2009 |
| Total Posts: 5333 |
|
|
| 02 Oct 2011 11:33 AM |
If you're interested in a more general case of this, Google "Generic For Lua".
Saying:
for i,v in pairs(t) do print(i,v) end
Iterates through every index-value pair in the table, and sets i to the index, and v to the value. So, if t was something like:
t = {42,1337,13} t[52] = "Fifty-two" t["Another index"] = "Another value"
Would output: 1 42 2 1337 3 13 52 Fifty-two Another index Another value
It is also equivalent to change the names of i & v, since they are just variables.
for q,z in pairs(t) do print(q,z) end
|
|
|
| Report Abuse |
|
|
TheWisest
|
  |
| Joined: 11 Nov 2010 |
| Total Posts: 7345 |
|
| |
|