I am trying to check if variable is in array so I used a solution found here.
The code below works fine if I pass value of tea direct in the include function as per below.
mycheck= ['Soap', 'Tea', 'Sugar'].include? 'Tea'
if mycheck == true
print("yes present")
else
print("not present")
end
My issues: My issue if I set value tea to a variable as per code below, it returns false
var_tea = 'Tea'
mycheck= ['Soap', 'Tea', 'Sugar'].include? var_tea
if mycheck == true
print("yes present")
else
print("not present")
end
Is there any other alternative way like using is_array()
, etc?