Filter

Parameters
func code

A filtering function that returns boolean or null.

comment

Returns a new filterfunc, when called by the game returns the result of evaluating func(). func will receive no arguments and must return a boolean: true/false.

note

Lua, 1.32.10: filterfunc extends from boolexpr->agent and must be explicitly destroyed with DestroyBoolExpr/DestroyFilter to prevent leaks. However, most functions from blizzard.j destroy passed boolexpr automatically.

note

Lua: Always returns a new handle unless the passed parameter is nil, in this case it MAY return the same handle depending on unknown conditions (consecutive calls are likely to reuse previous handle).

Jass: Returns same handle when creating multiple filters for the same function: Filter(function foo) == Filter(function foo) ("foo" can be non-constant and constant).

For this reason, do not destroy filterfuncs created with Filter in Jass, in the best case it does nothing but in the worst case it would affect some internals.

This behavior is similar to Condition.

pure
This function is pure. For the same values passed to it, it will always return the same value.
note

See: And, Or, Not, Condition, DestroyFilter; GetFilterUnit, GetFilterItem, GetFilterPlayer, GetFilterDestructable.

patch

1.00

Source
common.j
return type
filterfunc
Source code
native Filter           takes code func returns filterfunc