572
submitted 6 days ago by [email protected] to c/[email protected]
you are viewing a single comment's thread
view the rest of the comments
[-] [email protected] 11 points 6 days ago

I love something = condition and result1 or result2 in lua

[-] [email protected] 10 points 6 days ago* (last edited 6 days ago)
[-] [email protected] 1 points 6 days ago

Are you just referring to how Python uses the English and/or instead of the more common &&/||? I think what the user above you was talking about was Lua's strange ternary syntax using and/or.

[-] [email protected] 6 points 6 days ago* (last edited 6 days ago)

no, the linked table shows how python also returns the first non-falsey result of an a or b expression rather than just giving a boolean. it's useful for initialising optional reference args:

def foo(a: list = None)
    a = a or []

works with and as well.

[-] [email protected] 1 points 6 days ago* (last edited 6 days ago)

often I do a function called elvis XD with the next signature elvis(condition, res1, res2)

this post was submitted on 12 Jun 2025
572 points (98.6% liked)

Programmer Humor

24287 readers
500 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS