Does a && (b = 5/a) assign 5/a to b (for nonzero a)?
My friend says it doesn’t, but I’m confused why it wouldn’t.
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.
Your friend is wrong. For nonzero
a, the statementa && (b = 5/a)will assign the value5/atob.If
a == 0, then the conditional will short circuit and the assignment will not occur.