Fandom

WoWWiki

API wipe

104,631pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

WoW API < wipe

Wipes a table of all contents.

table = table.wipe(table)
wipe(table)

Arguments Edit

table 
Table - The table to be cleared.

Returns Edit

table 
Table - The empty table.

Example Edit

local tab = {}
tab.Hello = "Goodbye"
print(tab.Hello) -- print "Goodbye"
tab = table.wipe(tab)
print(tab.Hello) -- print nil

Notes Edit

  • While this function returns an empty table, it is not necessary to assign it to a variable.
local t = {"stuff"}
t = wipe(t)
print(#t) -- prints 0

local t = {"stuff"}
wipe(t)
print(#t) -- also prints 0
  • The difference between wipe(table) and table={} is that wipe removes the contents of the table, but retains the variable's internal pointer.
data={1,2,3}

copy=data
assert(copy==data)   -- they're the same object
copy={}
assert(copy~=data)   -- they're no longer the same:
assert(#copy==0)     -- the copy is expectedly empty,
assert(#data==3)     -- but the original table remains.

copy2=data
assert(copy2==data)  -- they're the same object
wipe(copy2)
assert(copy2==data)  -- they're still the same object:
assert(#copy2==0)    -- the copy is expectedly empty,
assert(#data==0)     -- and so is the original table.

Also on Fandom

Random Wiki