Skip to content

Commit

Permalink
Add doc for negation syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
pirj committed May 21, 2023
1 parent d4b7839 commit 580ee7d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/modules/ROOT/pages/node_pattern.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,16 @@ Imagine you want to check if the number is `odd?` and also positive numbers:

NOTE: Refer to <<Predicate methods>> to see how `odd?` works.

== `!` for Negation

Node pattern `(send nil? :sum !int _)` would match a `sum` call where the first argument is *not* a literal integer.
E.g.:

* it will match `sum(2.0, 3)`, as the first argument is of a `float` type
* it will not match `sum(2, 3)`, as the first argument is of an `int` type

NOTE: Negation operator works with other node pattern syntax elements, `{}`, `[]`, `()`, `$`, but not with `<>`.

== `$` for captures

You can capture elements or nodes along with your search, prefixing the expression
Expand Down

0 comments on commit 580ee7d

Please sign in to comment.