Describe the solution you'd like
When we use data in datatype it should return Boolean value as output.
Describe alternatives you've considered
Example
# with Array
arr = [1,2,3,4,5]
# with if-else
if 1 in arr {
print("Data found.")
}
else {
print("Not found.")
}
# Normal testing
print(2 in arr)
# with while loop
while 3 in arr {
# do something
}
# this should also work for HashMap as well.
Some test cases:
arr = [1,2,3,4,5]
assert 4 in arr
hash = {
"key1": "value1",
"key2": "value2"
}
assert "key2" in hash # This will search in HashMap->Keys
Additional context
Membership operators are very useful in Python world to check if any value exists in a datatype (Array, HashMap).
Describe the solution you'd like When we use
data in datatype
it should returnBoolean
value as output.Describe alternatives you've considered Example
Some test cases:
Additional context Membership operators are very useful in Python world to check if any value exists in a datatype (
Array
,HashMap
).