Skip to content

Conditional expression

The same as Python.

This is known as the 'ternary operator' in other languages.

def pseudo_fn(condition: bool):
    a: str = "foo" if condition else "bar"