Thread Tools Display Modes
Prev Previous Post   Next Post Next
08-05-14, 09:37 AM   #1
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Table iteration question

I was cleaning up some of my code when I noticed something that might be obvious, but I didn't realise before: Attempting to access variables that do not exist by iterating a table and calling functions on them does not result in any errors.

For example:

Lua Code:
  1. for k, v in pairs({ThisDoesNotExist, NorDoesThis}) do v:Show() end

This doesn't cause any errors.

Why is this? I find it rather counter-intuitive. I'm now going over all my code where I attempt to access global variables through tables and making sure I do a _G lookup by name instead - otherwise, I never know when one of the frames I'm trying to access no longer exists.

Last edited by Haleth : 08-05-14 at 09:39 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Table iteration 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