This looks like a short circuit way of writing code but I just can't understand it. Is there a specific way to read this kind of short circuit.
e.g:
n = n and int(n)
n = n or int(n)
This looks like a short circuit way of writing code but I just can't understand it. Is there a specific way to read this kind of short circuit.
e.g:
n = n and int(n)
n = n or int(n)
and
conditions return the last truthy value or the first falsy one. So if n
is falsy, n
will remain whatever value it was. If n
is truthy, it will be cast to an int
.