this post was submitted on 13 Dec 2025
643 points (97.6% liked)

Programmer Humor

27898 readers
2178 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
[–] OshaqHennessey@midwest.social 63 points 4 days ago (4 children)
function myFunction() {
  try {
    x = new Random().nextInt();
    if (x != 10) {
     throw "not 10";
    }
    else {
      return (10)
    }
    catch(err) {
      myFunction()
    }
  }
}

x = myFunction()

Commit notes: Added error handling

[–] firewallfail@lemmy.world 62 points 4 days ago (1 children)

Returning 10 instead of x when x finally ends up being 10 really ties it together.

[–] OshaqHennessey@midwest.social 28 points 4 days ago

I'm glad you noticed. That was my favorite part too.

load more comments (2 replies)