Created Montag 13 Januar 2020
Javascript / C
expression ? positive value : negative value
x>y ? x : y
If the expression is true x is returned if false y is returned.
Python
In Python there are 4 ways to do this.
Shortened if-else
x if x>y else y
Tuple
(y,x)[x>y]
Dictionary
{True: x, False: y} [x > y]
Lambda
(lambda:y,lambda:x)[x>y]()