Lore archive · Warcraft Wiki, 2023 dump
AllAreType
Last wiki revision 2010-01-18
This function is designed to make long If statements quicker and easier. Allows you to check lots of values at once for the same type
<PREFIX>_allAreType(type, param [,param [, ...]])
Note:
- If just the type parameter is given then the function returns true, as no parameters have failed the check (See example 'c' below).
- type: String - A string that represents the desired type of the values. See type for further help on this value.
- param: any - A list of values to check for the same, consistent type.
- result: Boolean - true if all of the params have the desired type, false if atleast one fails.
local a = <PREFIX>_allAreType("string", "Hello", DEFAULT_CHAT_FRAME:GetName) local b = <PREFIX>_allAreType("number", 65, tonumber("two")) local c = <PREFIX>_allAreType("table", {}, {5, 3, "Hello"}, "Bob")
-- edge cases local d = <PREFIX>_allAreType("function") local e = <PREFIX>_allAreType("function", nil)
a = true b = false c = false
-- edge cases d = true e = false
function <PREFIX>_allAreType(typeStr, ...) local value for i = 1, select('#', ...) do value = select(i, ...) if type(value) ~= typeStr then return false end end return true end
Categories
- User defined functions
Source
https://warcraft.wiki.gg/wiki/AllAreType · 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.