[Zeek] Part of const array with same value

TQ nothinrandom at gmail.com
Fri Dec 6 19:33:25 PST 2019


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,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ICSI.Berkeley.EDU/pipermail/zeek/attachments/20191206/44ff7cc1/attachment.html 


More information about the Zeek mailing list