Civilloquy
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
cm0002@lemmy.world to Programmer Humor@programming.dev · 5 days ago

Infallible Code

feddit.uk

message-square
42
fedilink
210

Infallible Code

feddit.uk

cm0002@lemmy.world to Programmer Humor@programming.dev · 5 days ago
message-square
42
fedilink
  • kubica@fedia.io
    link
    fedilink
    arrow-up
    63
    ·
    5 days ago

    You could save about half the code by only listing one boolean value and having the other as a default return at the bottom.

    Sometimes my genius is almost frightening.

    • LeFrog@discuss.tchncs.de
      link
      fedilink
      arrow-up
      14
      arrow-down
      1
      ·
      edit-2
      5 days ago

      This noob even forgot zero

      • PlexSheep@infosec.pub
        link
        fedilink
        arrow-up
        2
        ·
        3 days ago

        That and all negative values

    • prime_number_314159@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      4 days ago

      If small numbers are much more frequent, it’s better to return early. Really, you should gather statistics about the numbers the function is called with, and put the most frequent ones at the top.

    • justOnePersistentKbinPlease@fedia.io
      link
      fedilink
      arrow-up
      3
      ·
      5 days ago

      But this way your buddy in QA can build extra test cases and pay you back when he wins an award for most test cases created or some other corporate nonsense.

Programmer Humor@programming.dev

programmer_humor@programming.dev

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: !programmer_humor@programming.dev

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

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
Visibility: Public
globe

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

  • 768 users / day
  • 2.9K users / week
  • 5.93K users / month
  • 16.5K users / 6 months
  • 1 local subscriber
  • 25.1K subscribers
  • 1.4K Posts
  • 34.2K Comments
  • Modlog
  • mods:
  • Feyter@programming.dev
  • adr1an@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.5
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org