In python I can use this to check if the element in list a:
>>> a = range(10)
>>> 5 in a
True
>>> 16 in a
False
How this can be done in Ruby?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the
include?()method:EDIT:
(1..10)is Range in Ruby , in the case you want an Array(list) :