Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types/statements: Document delete of all elements #250

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions script-reference/statements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,18 @@ Example:
# In this example, "b" must have the "&optional" attribute
delete myrec$b;

.. versionadded:: 7.0

The ``delete`` statement can also be used to remove all elements from
a :zeek:type:`set`, :zeek:type:`table` or :zeek:type:`vector`.

Example:

.. code-block:: zeek

local myset = set("this", "test");
delete myset;


.. zeek:keyword:: event

Expand Down
22 changes: 22 additions & 0 deletions script-reference/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,14 @@ Remove individual table elements with :zeek:keyword:`delete`:
Nothing happens if the element with index value ``13`` isn't present in
the table.

.. versionadded:: 7.0

Removing all table elements can be done with the :zeek:keyword:`delete`, too:

.. code-block:: zeek

delete t;

.. note::

Indexing with complex types (such as records or sets) happens via hashing of
Expand Down Expand Up @@ -1256,6 +1264,15 @@ Elements are removed with :zeek:keyword:`delete`:

delete s[21/tcp];

.. versionadded:: 7.0

Removing all set elements can be done with the :zeek:keyword:`delete`, too:

.. code-block:: zeek

delete s;


Nothing happens if the element with value ``21/tcp`` isn't present in
the set.

Expand Down Expand Up @@ -1424,6 +1441,11 @@ false.
See the :zeek:keyword:`for` statement for info on how to iterate over
the elements in a vector.

.. versionadded:: 7.0

The :zeek:keyword:`delete` statement can be used to delete all elements
from a vector.

Vectorized operations
^^^^^^^^^^^^^^^^^^^^^

Expand Down
Loading