From a2eb68650623a34ca1d5285e974e65df7c60f482 Mon Sep 17 00:00:00 2001 From: Miccah Date: Sat, 20 Mar 2021 11:27:27 -0500 Subject: [PATCH] doc: document array .any() and .all() (#9386) --- doc/docs.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/docs.md b/doc/docs.md index 28c16d3e5f..91f564e751 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -713,6 +713,15 @@ println(upper_fn) // ['HELLO', 'WORLD'] `it` is a builtin variable which refers to element currently being processed in filter/map methods. +Additionally, `.any()` and `.all()` can be used to conveniently test +for elements that satisfy a condition. + +```v +nums := [1, 2, 3] +println(nums.any(it == 2)) // true +println(nums.all(it >= 2)) // false +``` + #### Multidimensional Arrays Arrays can have more than one dimension.