In #Python, you could write sensible and transparent code, like this:

if (curNode):
curNode = curNode.next

But if you prefer something that is functionally identical, but harder to read, try this:

curNode and (curNode := curNode.next)

Follow me for more great tips on how to make life hell for the next person working with your code (which could be you).

#ScottProgramming

@scottmiller42 Ruby lets you do something like this

curNode &&= curNode.next

For some reason I thought Python had added something like this too, but I can't find it.

@scottmiller42 This got me looking further, and I forgot that Ruby also allows

curNode = curNode&.next

which can be chained

userName = user&.profile&.name || "Anonymous"

@davidbody So if the expression on the right fails, is the variable on the left unchanged or is it set to nil? I could see either option being preferable depending on the programmerโ€™s preference.
@scottmiller42 It returns nil, which you can optionally turn into a different / default value using ||.

@scottmiller42 somewhat less intentionally obscure:

curNode = curNode.next if curNode else curNode