Name
HaveItem -- check if a table item exists (V6.0)
Synopsis
bool = HaveItem(t, key)
Library
table

Function
This function checks whether the specified table has an item at index key or not. If there is an item at this index, HaveItem() will return True. This is a convenience function for RawGet().

Note that if you pass a string in the key parameter, it will be converted to lower case automatically. If you don't want that, use RawGet() instead.

Starting with Hollywood 9.1, this function has a synonym called HasItem() which does the same but has a name that is grammatically correct.

Inputs
t
table to query
key
key to check
Results
bool
True or False depending on whether the item exists
Example
t = {x = 10, y = 20}
NPrint(HaveItem(t, "x"), HaveItem(t, "y"), HaveItem(t, "z"))
The code above will print 1 / 1 / 0 (= True, True, False).

Show TOC