this post was submitted on 17 Jan 2025
721 points (98.9% liked)

Programmer Humor

24980 readers
1985 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
 
you are viewing a single comment's thread
view the rest of the comments
[–] FooBarrington@lemmy.world 72 points 5 months ago (4 children)
try {
    operation();
} catch {
    // nice weather, eh?
}
[–] Karyoplasma@discuss.tchncs.de 14 points 5 months ago* (last edited 5 months ago) (1 children)

Starting with Java 21 (I think), they've introduced ignored variables, so you can now actually do this:

try {
    operation();
} catch (Exception _) {
    // nice weather, eh?
}

Edit: forgot that this is about JS lel

[–] jubilationtcornpone@sh.itjust.works 7 points 5 months ago (1 children)

So basically the same as a discard in C#?

[–] Karyoplasma@discuss.tchncs.de 1 points 5 months ago* (last edited 5 months ago)

Yeah, Python has it as well. I think the only real use of it is code readability since you declare that this variable will never be used.

[–] DjMeas@lemm.ee 10 points 5 months ago

☑️ PR Approved

[–] MajorHavoc@programming.dev 5 points 5 months ago

Thanks. I hate it.

[–] lengau@midwest.social 3 points 5 months ago
with contextlib.suppress(BaseException):
    do_thing()