check if collection contains given value
Parameters
contains? collection :string :dictionary :object :block :range
value :any
Attributes
at | :integer | check at given location within collection |
deep | | searches recursively in deep for a value. |
Returns
Examples
copy
arr: [1 2 3 4]
contains? arr 5 ; => false
contains? arr 2 ; => true
copy
user: #[
name: "John"
surname: "Doe"
]
contains? dict "John" ; => true
contains? dict "Paul" ; => false
contains? keys dict "name" ; => true
copy
contains? "hello" "x" ; => false
contains? "hello" `h` ; => true
copy
contains?.at:1 "hello" "el" ; => true
contains?.at:4 "hello" `o` ; => true
copy
print contains?.at:2 ["one" "two" "three"] "two"
; false
print contains?.at:1 ["one" "two" "three"] "two"
; true
copy
print contains?.deep [1 2 4 [3 4 [5 6] 7] 8 [9 10]] 6
; true
copy
user: #[
name: "John" surname: "Doe"
mom: #[ name: "Jane" surname: "Doe" ]
]
print contains?.deep user "Jane"
; true
Related