Just fixed a bug when if Something.nil? was yielding false when Something did not exist.
Somthing.count.nil? led to the same result
Fixed it by if Something.count < 1
Why could this not be working?
Any better ways than if x < 1 ?
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.
You can use zero? on Something.count
The reason for your “error” is that 0.nil? is false. 0 is not nil.
If you are testing for 0 elements in an array or a hash, use empty? on Something.