Lemmy.World
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
qaz to Programmer Humor@lemmy.mlEnglish · 2 years ago

Why use if/else when you can use try/if/catch?

message-square
8
link
fedilink
85

Why use if/else when you can use try/if/catch?

qaz to Programmer Humor@lemmy.mlEnglish · 2 years ago
message-square
8
link
fedilink
alert-triangle
You must log in or # to comment.
  • lowleveldata@programming.dev
    link
    fedilink
    English
    arrow-up
    18
    ·
    2 years ago

    Why use goto when you can throw exceptions to escape nested for loops?

    • fiah@discuss.tchncs.de
      link
      fedilink
      English
      arrow-up
      9
      ·
      2 years ago

      exceptions are just fancy gotos

      • wvenable@lemmy.ca
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 years ago

        Exceptions are fancy returns. Everything else is fancy goto, including returns…

  • speaker_hat@lemmy.one
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    2 years ago

    Why throwing an exception without a message, when you can use 0/0

  • HairHeel@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    ·
    2 years ago

    I don’t see a catch in the screenshot. Maybe this block just has a finally that cleans some things up before the exception is thrown?

    • qazOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      2 years ago

      It doesn’t have a catch block, and it isn’t supposed to throw any other exceptions inside the try block either.

  • katy ✨@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    2
    ·
    2 years ago

    Why use try/if/catch when you can use try/if/switch/catch?

Programmer Humor@lemmy.ml

programmerhumor@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 261 users / day
  • 504 users / week
  • 2.85K users / month
  • 9.17K users / 6 months
  • 11.4K local subscribers
  • 36.5K subscribers
  • 1.39K Posts
  • 33.4K Comments
  • Modlog
  • mods:
  • AgreeableLandscape@lemmy.ml
  • cat_programmer@lemmy.ml
  • UI: 0.19.12-3-ge0de14a9
  • BE: 0.19.12-4-gd8445881a
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org