I have:
num = ["jack","sparrow","terminator","leonidus"]
name = "jack"
The solution is:
if num.include? name
puts " Jack is here"
else
puts " Invite jack"
end
# => "Jack is here"
My old script is:
val = num.include? name
if val == "true"
puts " Jack is here"
else
puts " Invite jack"
end
# => "Invite jack"
Why is my old script not working? What is wrong with it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…