diff --git a/NEWS b/NEWS index 3cb0fd79b3..f160ec06b1 100644 --- a/NEWS +++ b/NEWS @@ -277,6 +277,9 @@ New Functionality - Bro now supports PPPoE over QinQ. +- An expression of the form v += e will append the value of the expression + e to the end of the vector v (of course assuming type-compatbility). + Changed Functionality --------------------- diff --git a/doc/script-reference/types.rst b/doc/script-reference/types.rst index f1d81f63ab..c3bacabbf8 100644 --- a/doc/script-reference/types.rst +++ b/doc/script-reference/types.rst @@ -599,6 +599,20 @@ Here is a more detailed description of each type: |v| + A particularly common operation on a vector is to append an element + to its end. You can do so using: + + .. code:: bro + + v += e; + + where if e's type is ``X``, v's type is ``vector of X``. Note that + this expression is equivalent to: + + .. code:: bro + + v[|v|] = e; + Vectors of integral types (``int`` or ``count``) support the pre-increment (``++``) and pre-decrement operators (``--``), which will increment or decrement each element in the vector.