MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/mwcaao/ternary_operators_at_their_maximum_potential/gvitbae/?context=3
r/badcode • u/SpeckyYT sadistic • Apr 22 '21
73 comments sorted by
View all comments
1
what does that || 4 does?
3 u/skrtpowbetch Apr 23 '21 edited Apr 23 '21 i might be wrong but i think what that says is the value assigned to type would be cmd.type if it’s truth-y, else 4. not completely sure thoughedit: “type” will equal cmd.type if cmd.type is defined, else 4 4 u/fforde_thinking Apr 23 '21 You were right the first time. If cmd.type == false then it will set "type" to 4
3
i might be wrong but i think what that says is the value assigned to type would be cmd.type if it’s truth-y, else 4. not completely sure though
edit: “type” will equal cmd.type if cmd.type is defined, else 4
4 u/fforde_thinking Apr 23 '21 You were right the first time. If cmd.type == false then it will set "type" to 4
4
You were right the first time. If cmd.type == false then it will set "type" to 4
1
u/fugogugo Apr 23 '21
what does that || 4 does?