View Single Post
09-01-23, 10:50 PM   #9
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
:GetChildren() doesn't return a table array of children. It returns multiple values, each one an independent pointer to each child object.

If you include a function in an expression, it always grabs the first return and discards everything else. When Lua gets to your index operation, it tries to run it on the child that happened to have been grabbed. There's likely to be nothing there, so this would result in nil.

An exception to this is if a function call is the last in a list of expressions or parameters to a function call. For example, table.new(self:GetChildren()) passes all children to table.new(), which then creates a table containing all the children. This is equivalent to wrapping it in a table constructor like {self:GetChildren()}

Note table.new() is from the RestrictedTables implementation and only exists within the RestrictedEnvironment.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 09-01-23 at 11:30 PM.
  Reply With Quote