mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00

I ran into wanting to iterate over just the values of a vector and wondering whether that could just work. This adds support for the following, where v will be value of vec[i]. local vec = vector("zero", "one", "two"); for ( i, v in vec ) print i, v;
20 lines
256 B
Text
20 lines
256 B
Text
# @TEST-EXEC: zeek -b %INPUT >out
|
|
# @TEST-EXEC: btest-diff out
|
|
|
|
local vec: vector of string = { "zero", "one", "two" };
|
|
vec[4] = "four";
|
|
|
|
for ( i, v in vec )
|
|
{
|
|
print i, v;
|
|
}
|
|
|
|
for ( [i], v in vec )
|
|
{
|
|
print i, v;
|
|
}
|
|
|
|
for ( _, v in vec )
|
|
{
|
|
print v;
|
|
}
|