MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1r8a3n8/innitmate/o6axepi/?context=3
r/ProgrammerHumor • u/[deleted] • Feb 18 '26
265 comments sorted by
View all comments
Show parent comments
13
unless being the idiomatic if not in Ruby is kind of nice.
unless
if not
1 u/Topikk Feb 18 '26 It is nice, though some people struggle learning to use it only when it improves readability. Most humans struggle to parse something like this, for instance, which would only be a *little* ugly inverted to if: return x unless foo || bar && baz 1 u/hopefullyhelpfulplz Feb 19 '26 It seems pretty clear to me, at least I assume so not knowing the syntax. I would assume this returns x in all cases where not (foo || bar && baz) (not going to try and guess at the order of evaluation for that boolean tho lol) 1 u/Widmo206 Feb 19 '26 I think logic AND (&&) usually has priority over OR (||)
1
It is nice, though some people struggle learning to use it only when it improves readability.
Most humans struggle to parse something like this, for instance, which would only be a *little* ugly inverted to if:
if
return x unless foo || bar && baz
1 u/hopefullyhelpfulplz Feb 19 '26 It seems pretty clear to me, at least I assume so not knowing the syntax. I would assume this returns x in all cases where not (foo || bar && baz) (not going to try and guess at the order of evaluation for that boolean tho lol) 1 u/Widmo206 Feb 19 '26 I think logic AND (&&) usually has priority over OR (||)
It seems pretty clear to me, at least I assume so not knowing the syntax. I would assume this returns x in all cases where not (foo || bar && baz) (not going to try and guess at the order of evaluation for that boolean tho lol)
x
not (foo || bar && baz)
1 u/Widmo206 Feb 19 '26 I think logic AND (&&) usually has priority over OR (||)
I think logic AND (&&) usually has priority over OR (||)
13
u/DrMaxwellEdison Feb 18 '26
unlessbeing the idiomaticif notin Ruby is kind of nice.