This is the ThingsDB documentation for version v0, click here for the latest version!


This function removes and returns the value of the first item in the list that satisfies the callback function. Otherwise nil is returned if no alternative return value is specified.

This function generates an event (except when called on a variable).


list.remove(callback, [alt])


Argument Type Description
callback closure Closure to execute on each value until the closure evaluates to true.
alt any (optional) Alternative value which is returned if no item has passed the callback test.

Explanation of the callback argument:

Iterable Arguments Description
list item, index Iterate over items in the list. Both item and index are optional.

The alt argument will be lazily evaluated. Consider the following example:
elems.remove(|e| ( == "foo"), items.pop());
Here, the item will only be popped, in case e with name foo is not found in elems.

Return value

The value of the first item in the list that satisfies the provided testing function; otherwise, nil or a specified alternative value is returned.


This code shows an example using remove() on a list:

tmp = [1, 2, 3, 4];
    tmp.remove(|x| (x % 2 == 0)),

Return value in JSON format