Thread Tools Display Modes
10-15-05, 10:04 AM   #1
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
Function() question

When I use the function() command, what can I put between both brakcets and what are they for?
For example, what's the difference between

Code:
local function rollCompare(i,j)
  return rollTable[i] < rollTable[j];
end
and

Code:
local function rollCompare()
  return rollTable[i] < rollTable[j];
end
  Reply With Quote
10-15-05, 11:15 AM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
You can send local values to a function with the paremeters.

local function rollCompare(i,j)
return rollTable[i] < rollTable[j];
end

In the above example, i and j are send to the function: local val = rollCompare(3,5) is the same as:

i=3
j=5
local val = rollCompare() with the example below

local function rollCompare()
return rollTable[i] < rollTable[j];
end

It's a lot tidier to keep stuff in parameters. They're local and put on the stack so won't create garbage to collect.
  Reply With Quote
10-15-05, 12:13 PM   #3
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
Thanks a lot man
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Function() question

Thread Tools
Display Modes

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