Part of const array with same value
TQ <[email protected]> Fri, 6 Dec 2019 19:33:25 -0800
| Newsgroups | gmane.comp.security.detection.bro |
|---|---|
| Message-ID | <CAM2MKSpuMp=9mhs15ZDYB8xVb_XC061r_XndF1jNrsgUkjeeAw@mail.gmail.com> |
--===============1129720768==
Content-Type: multipart/alternative; boundary="0000000000004e6bbd059914d57e"
--0000000000004e6bbd059914d57e
Content-Type: text/plain; charset="UTF-8"
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,
--0000000000004e6bbd059914d57e
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hello Zeekers,<br><div><br></div><div>What is the best way=
to represent indices of an array with the same value?=C2=A0 Let's say =
I declare a constant string array used for enumeration called 'test'=
;.=C2=A0 Values 0 and 1 has some unique value, but anything from 2 and 7 ha=
s a constant value of 'test2'.=C2=A0 Is there a quicker way of repr=
esenting this or would I need to manually set it?</div><div><br></div><div>=
const test =3D {<br>=C2=A0 =C2=A0 [0] =3D "test0",<br>=C2=A0 =C2=
=A0 [1] =3D "test1",</div><div><div>=C2=A0 =C2=A0 [2] =3D "t=
est2",<br>=C2=A0 =C2=A0 [3] =3D "test2",</div><div><div>=C2=
=A0 =C2=A0 [4] =3D "test2",<br>=C2=A0 =C2=A0 [5] =3D "test2&=
quot;,</div><div></div></div><div></div><div><div>=C2=A0 =C2=A0 [6] =3D &qu=
ot;test2",<br>=C2=A0 =C2=A0 [7] =3D "test2",</div><div>
=C2=A0 =C2=A0 [8] =3D "test3",
<br></div><div></div></div>=C2=A0 =C2=A0 } &default=3Dfunction(i: count=
):string { return fmt("test(%x)", i); } &redef;<br></div><div=
><br></div><div>Thanks,</div></div>
--0000000000004e6bbd059914d57e--
--===============1129720768==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Zeek mailing list
[email protected]
http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/zeek
--===============1129720768==--