Thread Tools Display Modes
10-10-05, 08:28 AM   #1
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
for k,v in ..... do.... explained?

I've never understood what the following statement ment:
Code:
local _, class = UnitClass('player')
local _, class = UnitClass('player')

Global_options = {'a','b','c'}
WARRIOR_options = {'d','e','f'}
ROGUE_options = {'g','h','i'}

for k,v in getglobal(class .. '_options') do
    table.insert(Global_options, v)
end
I understand what it does, it gets the global called class and inserts it in the Global_option table with v as it's key. Wht I don't understand is the k and v statements. What are they? Do they have a numerical value? What does the "in" do? I really don't understand anything at all
  Reply With Quote
10-10-05, 09:38 AM   #2
mondinga
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 66
For each key & it's value as k & v in table, do something. In this case, iterating over the WARRIOR_options array would return first k=1, v=d, then k=2, v=e, and finally k=3, v=f.
  Reply With Quote
10-10-05, 10:13 AM   #3
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
Lol I fell kinda dumb :P I've really been having problems with lua and talbes Thanks mate.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » for k,v in ..... do.... explained?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off