Question

If I want to ensure that an if statement only executes if BOTH of two conditions are true, should I be using & or && between the clauses of the statement?

For example, should I use

if a == 5 & b == 4

or

if a == 5 && b == 4

I understand that the former is elementwise and the latter is capable of short-circuiting but am not clear on what this means.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top