Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/awelzel/document-delete-al…
Browse files Browse the repository at this point in the history
…l-elements'

* origin/topic/awelzel/document-delete-all-elements:
  types/statements: Document delete of all elements
  • Loading branch information
awelzel committed Feb 27, 2024
2 parents b8666f0 + 42df9c2 commit 8b0be9a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
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

0 comments on commit 8b0be9a

Please sign in to comment.