doc: document `!in` (#8546)
parent
81789ee106
commit
12e8e31bb2
|
@ -1046,15 +1046,18 @@ match mut x {
|
||||||
### In operator
|
### In operator
|
||||||
|
|
||||||
`in` allows to check whether an array or a map contains an element.
|
`in` allows to check whether an array or a map contains an element.
|
||||||
|
To do the opposite, use `!in`.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
nums := [1, 2, 3]
|
nums := [1, 2, 3]
|
||||||
println(1 in nums) // true
|
println(1 in nums) // true
|
||||||
|
println(4 !in nums) // true
|
||||||
m := {
|
m := {
|
||||||
'one': 1
|
'one': 1
|
||||||
'two': 2
|
'two': 2
|
||||||
}
|
}
|
||||||
println('one' in m) // true
|
println('one' in m) // true
|
||||||
|
println('three' !in m) // true
|
||||||
```
|
```
|
||||||
|
|
||||||
It's also useful for writing boolean expressions that are clearer and more compact:
|
It's also useful for writing boolean expressions that are clearer and more compact:
|
||||||
|
|
Loading…
Reference in New Issue