Module:table/contains

Revision as of 18:16, 16 February 2026 by Sware (talk | contribs) (Created page with "local table_find_module = "Module:table/find" local function table_find(...) table_find = require(table_find_module) return table_find(...) end --[==[ Given a list and a value to be found, returns {true} if the value is in the array portion of the list, or {false} if not. `options` is an optional table of additional options to control the behavior of the operation. The following options are recognized: * `comparison`: Function of two arguments to compare whether `it...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:table/contains/doc

local table_find_module = "Module:table/find"

local function table_find(...)
	table_find = require(table_find_module)
	return table_find(...)
end

--[==[
Given a list and a value to be found, returns {true} if the value is in the array portion of the list, or {false} if not.

`options` is an optional table of additional options to control the behavior of the operation. The following options are recognized:
* `comparison`: Function of two arguments to compare whether `item` is equal to an existing item in `list`. If unspecified, items are considered equal if either the standard equality operator {==} or {deepEquals} return {true}. As a special case, if the string value {"=="} is specified, then the standard equality operator alone will be used.
* `key`: Function of one argument to return a comparison key, which will be used with the comparison function. The key function is applied to both `item` and the existing item in `list` to compare against, and the comparison is done against the results.]==]
return function(...)
	return table_find(...) and true or false
end