I was under the impression that conditions joined with && were executed in sequence, such that the following would return true:
a = "adasd"
> b = a && b.present?
=> false
Thoughts?
Thanks!
–Peter
-
note:
b = a
=> “adasd”b.present?
=> true
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.
When you say this:
You’re declaring
bas a local variable but it will beniluntil the right side of the assignment is evaluated. In particular,bwill benilwhen you callpresent?on it and the conjunction will be false makingbfalse.When you do this:
bwill have the value'pancakes'when you callpresent?on it so you get a true return fromb.present?.