- Notifications
You must be signed in to change notification settings - Fork 0
Ternary Operator
Ariel Balter edited this page Jun 13, 2018 · 1 revision
https://www.co.benton.or.us/health/page/developmental-diversity-program
Another syntax which can be used (compatible with versions before 2.5): result = (lambda:y, lambda:x)[a > b]() where operands are [lazily evaluated][2]. Another way is by indexing a tuple (which isn't consistent with the conditional operator of most other languages): result = (y, x)[a > b] or explicitly constructed dictionary: result = {True: x, False: y}[a > b]