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

Infallible Code

feddit.uk

message-square
55
link
fedilink
265

Infallible Code

feddit.uk

cm0002@lemmy.world to Programmer Humor@programming.dev · 2 days ago
message-square
55
link
fedilink
  • kubica@fedia.io
    link
    fedilink
    arrow-up
    89
    ·
    2 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.

    • prime_number_314159@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      1 day 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.

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

      This noob even forgot zero

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

        That and all negative values

    • justOnePersistentKbinPlease@fedia.io
      link
      fedilink
      arrow-up
      5
      ·
      2 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.

  • 1.11K users / day
  • 4.65K users / week
  • 7.7K users / month
  • 19.9K users / 6 months
  • 1 local subscriber
  • 25K subscribers
  • 950 Posts
  • 19K Comments
  • Modlog
  • mods:
  • adr1an@programming.dev
  • Feyter@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.12
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org