File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed
docs/language/ql-handbook Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -262,6 +262,10 @@ multiple binding set annotations, for example::
262262 x + 1 = y
263263 }
264264
265+ from int x, int y
266+ where y = 42 and plusOne(x, y)
267+ select x, y
268+
265269Multiple binding sets specified this way are independent of each other. The above example means:
266270 - If ``x `` is bound, then ``x `` and ``y `` are bound.
267271 - If ``y `` is bound, then ``x `` and ``y `` are bound.
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ For example::
8383 result = x * y
8484 }
8585
86- This predicates returns the following results:
86+ This predicate returns the following results:
8787
8888+---+---+--------+
8989| x | y | result |
@@ -96,8 +96,14 @@ This predicates returns the following results:
9696+---+---+--------+
9797
9898A benefit of writing a query predicate instead of a select clause is that you can call the
99- predicate in other parts of the code too. In contrast, the select clause is like an anonymous
100- predicate, so you can't call it later.
99+ predicate in other parts of the code too. For example, you can call ``getProduct `` inside
100+ the body of a :ref: `class <classes >`::
101+
102+ class MultipleOfThree extends int {
103+ MultipleOfThree() { this = getProduct(_, _) }
104+ }
105+
106+ In contrast, the select clause is like an anonymous predicate, so you can't call it later.
101107
102108It can also be helpful to add a ``query `` annotation to a predicate while you debug code. That
103109way you can explicitly see the set of tuples that the predicate evaluates to.
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ base types.
106106
107107A class can extend multiple types. See :ref: `multiple-inheritance ` below.
108108
109- To be a valid, a class:
109+ To be valid, a class:
110110 - Must not extend itself.
111111 - Must not extend a :ref: `final ` class.
112112 - Must not extend types that are incompatible. (See :ref: `type-compatibility `.)
@@ -147,7 +147,11 @@ predicate from the :ref:`above <defining-class>` class::
147147
148148 1.(OneTwoThree).getAString()
149149
150- This call returns the results ``"One, two or three: 1" ``.
150+ This call returns the result ``"One, two or three: 1" ``.
151+
152+ The expression ``(OneTwoThree) `` is a :ref: `cast <casts >`. It ensures that ``1 `` has type
153+ ``OneTwoThree `` instead of just ``int ``. Therefore, it has access to the member predicate
154+ ``getAString() ``.
151155
152156Member predicates are especially useful because you can chain them together. For example, you
153157can use ``toUpperCase() ``, a built-in function defined for ``string ``::
You can’t perform that action at this time.
0 commit comments