Skip to content

Commit

Permalink
docs: fix ++ and -- text wrt undefined vars
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarchini committed Apr 22, 2019
1 parent 808d56c commit 47ab5cd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/reference_guide.md
Expand Up @@ -544,12 +544,14 @@ i: 5

`++` and `--` can be used to conveniently increment or decrement counters in maps or variables.

Note that variables will be implictly declared and initalized to 0 if not already declared or defined.
Note that maps will be implictly declared and initalized to 0 if not already
declared or defined. Scratch variables must be initalized before using these
operators.

Example - variable:

```
bpftrace -e 'BEGIN { $x++; $x++; printf("x: %d\n", $x); }'
bpftrace -e 'BEGIN { $x = 0; $x++; $x++; printf("x: %d\n", $x); }'
Attaching 1 probe...
x: 2
^C
Expand Down

0 comments on commit 47ab5cd

Please sign in to comment.