Skip to content
everloot

Lore archive · Warcraft Wiki, 2023 dump

API wipe

Last wiki revision 2022-08-03

Wipes a table of all contents. table = table.wipe(table) wipe(table)

  • table: - The table to be cleared.
  • table: - The empty table.

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

  • 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.

  • wipe(table) preserves any metatable set to table.

table={1,2,3} meta={__index={["foo"]="bar"}} setmetatable(table,meta) print(table["foo"])-- prints "bar" wipe(table) print(table["foo"])-- still prints "bar"

Source

https://warcraft.wiki.gg/wiki/API_wipe · retrieved 2023-11-13 · CC BY-SA 4.0

Converted from wikitext with templates, tables and images removed, so some sentences may be missing values.

This archive predates WoW: Forever. For collected gameplay facts see the Forever database. Search the archive.