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.
Your friend is wrong. For nonzero a
, the statement a && (b = 5/a)
will assign the value 5/a
to b
.
If a == 0
, then the conditional will short circuit and the assignment will not occur.