From 12e8e31bb2891f83cda666d5c689cca6f5bfef7e Mon Sep 17 00:00:00 2001 From: Ruofan XU <47302112+SleepyRoy@users.noreply.github.com> Date: Fri, 5 Feb 2021 23:45:20 +0800 Subject: [PATCH] doc: document `!in` (#8546) --- doc/docs.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/docs.md b/doc/docs.md index 05aa69c27b..9ea863f530 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -1046,15 +1046,18 @@ match mut x { ### In operator `in` allows to check whether an array or a map contains an element. +To do the opposite, use `!in`. ```v nums := [1, 2, 3] println(1 in nums) // true +println(4 !in nums) // true m := { 'one': 1 'two': 2 } println('one' in m) // true +println('three' !in m) // true ``` It's also useful for writing boolean expressions that are clearer and more compact: