Skip to content

Commit 065a993

Browse files
committed
Add docs for ranges' .sum and .contains
1 parent 08a5ebb commit 065a993

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

docs/cpp2/expressions.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ For more examples, see also the examples in the previous two sections on `is` an
251251
252252
For example:
253253
254-
``` cpp title="Using ..< and ..= for ranges" hl_lines="5 11"
254+
``` cpp title="Using ..< and ..= for ranges" hl_lines="5 11 16-18"
255255
test: (v: std::vector<std::string>) =
256256
{
257257
// Print strings from "Nonesuch" (if present) onward
@@ -266,6 +266,10 @@ test: (v: std::vector<std::string>) =
266266
std::cout << " (e)$ (v[e])$\n";
267267
}
268268
}
269+
270+
std::cout << " ((1 ..= 100).sum())$ \n";
271+
std::cout << " ((1 ..< 100).contains(99))$ \n";
272+
std::cout << " ((1 ..< 100).contains(100))$ \n";
269273
}
270274
271275
main: () = {
@@ -277,6 +281,9 @@ main: () = {
277281
// Wumpus
278282
// 1 Grue
279283
// 2 Nonesuch
284+
// 5050
285+
// true
286+
// false
280287
```
281288

282289

0 commit comments

Comments
 (0)