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

Add text to 'as' operator about set/vector conversion #203

Merged
merged 1 commit into from
Aug 11, 2023
Merged
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
14 changes: 14 additions & 0 deletions script-reference/operators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ Only the following kinds of type casts are supported currently:
- A value of declared type :zeek:type:`any` can be cast to its actual
underlying type.
- All values can be cast to their declared types (i.e., this is a no-op).
- :zeek:type:`set` and :zeek:type:`vector` values can be converted into each
other, with the following limitations: (1) A :zeek:type:`set` being converted
into a :zeek:type:`vector` can only have a single index type. Converting a
set with multiple index types will return an error. (2) The :zeek:type:`set`
and :zeek:type:`vector` types must have the same internal type.

The function in this example tries to cast a value to a string:

Expand All @@ -352,6 +357,15 @@ The function in this example tries to cast a value to a string:
s = (a as string);
}

The function in this example converts a set to a vector:

.. code-block:: zeek

function example()
{
local s: set[count] = { 1, 2, 3 };
local v = s as vector of count;
}

Other operators
---------------
Expand Down