by sbergot · 3y ago · 0 comments
Declarative way: c = condition ? a : b
Imperative way:
c = null
if condition:
c = a
else:
c = bAnd in Python at least, it would be:
if condition:
c = a
else:
c = b
(i.e. no upfront declaration of c)As being declarative is about expectations, one translation could be:
I expect that "either both a and the condition to be true, or b true and the condition false" once the computation done.
a when: condition
b when: not conditionThis is a definition after all.
c = a if condition else c = b
Whether c is implicit or not doesn't matter too much.
I think the comment you respond to is still correct.