Derock's Lemmy
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Maven (famous)@lemmy.zip to Programmer Humor@programming.dev · 5 days ago

Modern Programming

lemmy.zip

message-square
70
fedilink
1

Modern Programming

lemmy.zip

Maven (famous)@lemmy.zip to Programmer Humor@programming.dev · 5 days ago
message-square
70
fedilink
  • kn0wmad1c@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    4 days ago

    num % 2 isn’t a boolean result in any of these languages, so I feel like it would always output “odd”

    • Sleepless One@lemmy.ml
      link
      fedilink
      English
      arrow-up
      0
      ·
      4 days ago

      In JS at least, there’s a concept of truthiness and falsiness. 0, undefined, null, and a few other non-boolean values are treated as false if used in conditionals and logical operations, while every other value is treated as true. I’m pretty sure python has something similar.

      • Hammerheart@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        3 days ago

        It does. Empty collections, 0, None

    • marcos@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      4 days ago

      You’d be surprised.

      But seriously, numbers can be used as booleans in an impressive number of languages. Including machine code for almost every machine out there.

    • Kaboom@reddthat.com
      link
      fedilink
      arrow-up
      0
      ·
      4 days ago

      0 is false in C, Python, and JS. It should work

    • Colloidal@programming.dev
      link
      fedilink
      arrow-up
      0
      ·
      4 days ago

      The joys of dynamic typing.

    • moomoomoo309@programming.dev
      link
      fedilink
      English
      arrow-up
      0
      ·
      4 days ago

      All of those languages will convert numbers into booleans, 0 is false, all other numbers are true.

      • kn0wmad1c@programming.dev
        link
        fedilink
        English
        arrow-up
        0
        ·
        4 days ago

        Ah that makes sense.

        • SatyrSack@lemmy.sdf.org
          link
          fedilink
          arrow-up
          0
          ·
          4 days ago

          It doesn’t make sense. I understand it, but it doesn’t make sense.

    • Maven (famous)@lemmy.zipOP
      link
      fedilink
      arrow-up
      0
      ·
      4 days ago

      In JS 0 is the same as False

      • Lifter@discuss.tchncs.de
        link
        fedilink
        arrow-up
        0
        ·
        4 days ago

        They are not the same, but 0 can be implicitly converted to false.

        What do you get if you do: 0 === false

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: [email protected]

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.

  • 72 users / day
  • 470 users / week
  • 1.59K users / month
  • 3.96K users / 6 months
  • 0 local subscribers
  • 24.2K subscribers
  • 1.03K Posts
  • 20.3K Comments
  • Modlog
  • mods:
  • Feyter@programming.dev
  • adr1an@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.5
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org