Quantcast
WoWInterface - View Single Post - Add table to list
View Single Post
02-21-21, 09:09 PM   #7
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,418
Wipe empties the contents of the table

Lua Code:
  1. table.insert(addClassSpellList, 1, tempSpellChatList)
  2. wipe(addClassSpellList[1])
  3. --is the same as
  4. wipe(tempSpellChatList)

In your code, there is no need to wipe anything as tempSpellChatList is being assigned a brand new table (any time you see = {} means a brand new table has been created.)

tempSpellChatList can be made local in the function as you're not saving anything through reuse.

Run the following and see the table id's (references, memory addresses, pointers...)
Code:
local a={"1"} 
print("A", a, a[1]) 

local b = a 
print("B", b, b[1]) 

wipe(a) 
print("wipe", "A")

print("B", b, b[1])

a = {}
print("A", a) -- a will point to a new table
print("B", b) -- b still holds the old pointer
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 02-21-21 at 09:30 PM.
  Reply With Quote