▲ 624 ▼ know the features of your language (lemmy.world) submitted 2 years ago by jroid8@lemmy.world to c/programmerhumor@lemmy.ml 145 comments fedilink hide all child comments
[–] murtaza64@programming.dev 3 points 2 years ago* (1 child) You don't need the and right? Can't it just be return a or b This doesn't work if a is falsy non-null actually permalink fedilink source parent hideshow 1 child comment replies: [–] cerement@slrpnk.net 1 point 2 years ago it’s just return a and b or c is the closest Lua has to a ternary operator, but yes, for the above you could shorten it to return a or b (“or returns the first argument if true, otherwise second argument is returned”) permalink fedilink source parent
[–] cerement@slrpnk.net 1 point 2 years ago it’s just return a and b or c is the closest Lua has to a ternary operator, but yes, for the above you could shorten it to return a or b (“or returns the first argument if true, otherwise second argument is returned”) permalink fedilink source parent