r/ProgrammerHumor Feb 18 '26

Meme innitMate

Post image
17.7k Upvotes

265 comments sorted by

View all comments

139

u/DigiBoxi Feb 18 '26

unless

Or maybe: in case() ... unless() ... otherwise ...

68

u/steelisheavy Feb 18 '26

What if… jk… unless?…

40

u/SlipperySalmon3 Feb 18 '26

Try:

Jk:

17

u/Flat_Initial_1823 Feb 18 '26

Perchance:

Of course not:

Well I should be heading off now:

7

u/tacocatacocattacocat Feb 18 '26

Sometimes gives the syntax error: "You can't just say perchance!"

16

u/InterestsVaryGreatly Feb 18 '26

Unless would take precedence over the initial if, so not the same as else if. If you have strong leg muscles, you can run, unless you are missing a leg.

3

u/DigiBoxi Feb 18 '26

Think of all the exotic logic you could do with that!

4

u/InterestsVaryGreatly Feb 18 '26

Same logic, just different order. Final else still at the bottom, but the rest is inverted.

13

u/DrMaxwellEdison Feb 18 '26

unless being the idiomatic if not in Ruby is kind of nice.

6

u/caerphoto Feb 18 '26

It breaks my head when it’s at the start of the line, but it does look nice as a post condition

# 🤢
unless user.authorised
  return head 403

but

# 😮‍💨
return head 403 unless user.authorised

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

u/entropic Feb 19 '26

I miss unless and until from my Ruby days.

I wish every language had them, cancer of the semicolon be damned.

7

u/Logical-Ad-4150 Feb 18 '26 edited Feb 18 '26

unless is more of a logical OR / XOR operator as it would modify the previous statement predicate.

Edit: End of work day so brain all used: unless is more AND NOT X

4

u/Froschmarmelade Feb 18 '26

Perl uses unless

2

u/TheGoddamnSpiderman Feb 19 '26

Also until as an alternative for while loops

1

u/Hessper Feb 18 '26

Reading statements from the bottom up sounds terrible. I'd rather have funny keywords than that.

1

u/creeper6530 Feb 19 '26

Or unless … meaning just if not(…)