I use the postfix if / if form only for defensive constructs:
return if not valid break if finished continue if not important
Not for assignments:
mood = greatlyImproved if singing
My reasoning is based on the fact that the condition is hidden on the right, and the control flow path is at the same level of indentation.
When I look at the code block, I can scan left and see the control flow. The code that follows the return is obviously available only when the return happens sometimes, so it stands out. This is a recognizable pattern and its presence on one line is better than two.
However, the assignment does not stand out, and it is easier to skip the condition on the right. If assignment occurs only occasionally, I think if indented is clearer:
if singing mood = greatlyImproved
mbarkhau
source share