[Zeek] Part of const array with same value

TQ nothinrandom at gmail.com
Sat Dec 7 11:31:11 PST 2019


My use case is for enumeration.  This array is typically declared in
consts.zeek; you would call it in main.zeek.  I mean you could write a
switch statement, but now main.zeek would definitely blow up quite a bit.

Thanks,

On Sat, Dec 7, 2019 at 6:00 AM kilotao at gmail.com <kilotao at gmail.com> wrote:

> What's the use of this array?
>
> On Fri, Dec 6, 2019, 10:36 PM TQ <nothinrandom at gmail.com> wrote:
>
>> Hello Zeekers,
>>
>> What is the best way to represent indices of an array with the same
>> value?  Let's say I declare a constant string array used for enumeration
>> called 'test'.  Values 0 and 1 has some unique value, but anything from 2
>> and 7 has a constant value of 'test2'.  Is there a quicker way of
>> representing this or would I need to manually set it?
>>
>> const test = {
>>     [0] = "test0",
>>     [1] = "test1",
>>     [2] = "test2",
>>     [3] = "test2",
>>     [4] = "test2",
>>     [5] = "test2",
>>     [6] = "test2",
>>     [7] = "test2",
>>     [8] = "test3",
>>     } &default=function(i: count):string { return fmt("test(%x)", i); }
>> &redef;
>>
>> Thanks,
>> _______________________________________________
>> Zeek mailing list
>> zeek at zeek.org
>> http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/zeek
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ICSI.Berkeley.EDU/pipermail/zeek/attachments/20191207/edbf8c6f/attachment.html 


More information about the Zeek mailing list