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

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

lemmy.world

message-square
7
fedilink
73

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

lemmy.world

qaz@lemmy.world to Programmer Humor@lemmy.mlEnglish · 2 years ago
message-square
7
fedilink
alert-triangle
You must log in or register to comment.
  • lowleveldata@programming.dev
    link
    fedilink
    English
    arrow-up
    14
    ·
    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
      7
      ·
      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…

  • 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?

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

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

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

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

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: !programmerhumor@lemmy.ml

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.

  • 52 users / day
  • 1.77K users / week
  • 2.6K users / month
  • 10.3K users / 6 months
  • 437 local subscribers
  • 35.7K subscribers
  • 1.73K Posts
  • 38.3K Comments
  • Modlog
  • mods:
  • AgreeableLandscape@lemmy.ml
  • cat_programmer@lemmy.ml
  • BE: 0.19.8
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org