minigubben's lemmy
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
jroid8@lemmy.world to Programmer Humor@lemmy.ml · 2 years ago

know the features of your language

lemmy.world

message-square
145
fedilink
622

know the features of your language

lemmy.world

jroid8@lemmy.world to Programmer Humor@lemmy.ml · 2 years ago
message-square
145
fedilink
  • ABC123itsEASY@lemmy.world
    link
    fedilink
    arrow-up
    12
    arrow-down
    2
    ·
    2 years ago

    Yea uh is this actually equivalent? In all of those other cases you’re checking if a is null and in the last case my understanding is it is checking to see if a is falsely. In the case that a is 0, or undefined, or an empty array or any other kind of non null falsey value, then the behavior would be different.

    • Ebber@lemmings.world
      link
      fedilink
      arrow-up
      21
      ·
      2 years ago

      In C# that last one is the null propagation operator. If a is not null then a, else b.

      • ABC123itsEASY@lemmy.world
        link
        fedilink
        arrow-up
        7
        ·
        2 years ago

        Ah interesting one of those cases where this could be one of a few languages. I was reading it as JS.

        • dukk@programming.dev
          link
          fedilink
          arrow-up
          3
          ·
          2 years ago

          I thought it was TS/JS too, but the way those braces are below the if statements makes it feel more like C#.

          • darkpanda@lemmy.ca
            link
            fedilink
            arrow-up
            2
            ·
            2 years ago

            K&R for life

    • Rednax@lemmy.world
      link
      fedilink
      arrow-up
      13
      ·
      2 years ago

      Even in Javascript, the ?? operator checks explicitly for null or undefined. So it added undefined, but not 0 or false. But adding undefined sounds like a good addition for this operator.

      See the Javascript section of: https://wikipedia.org/wiki/Null_coalescing_operator#Examples_by_languages

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.

  • 221 users / day
  • 2.08K users / week
  • 2.53K users / month
  • 4.01K users / 6 months
  • 2 local subscribers
  • 36.4K subscribers
  • 1.75K Posts
  • 36.2K Comments
  • Modlog
  • mods:
  • cat_programmer@lemmy.ml
  • AgreeableLandscape@lemmy.ml
  • BE: 0.19.7
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org