ubergeek77's Lemmy
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Sleepzy@feddit.it to Programmer Humor@lemmy.ml · 1 年前

Elvis

feddit.it

external-link
message-square
33
fedilink
145
external-link

Elvis

feddit.it

Sleepzy@feddit.it to Programmer Humor@lemmy.ml · 1 年前
message-square
33
fedilink
alert-triangle
You must log in or # to comment.
  • Blue_Morpho@lemmy.world
    link
    fedilink
    arrow-up
    45
    ·
    1 年前

    I never heard it called the Elvis operator! Thanks!

    • The Ramen Dutchman@ttrpg.network
      link
      fedilink
      arrow-up
      28
      ·
      1 年前

      It’s because if you turn it 90° to the right, it looks like Elvis’ hair with two eyes underneath!

      • disguy_ovahea@lemmy.world
        link
        fedilink
        arrow-up
        22
        ·
        1 年前

        I saw it the other way, with the question mark as the curl of his lip.

        Elvis lip

        • Dwemthy (he/him)@lemdro.id
          link
          fedilink
          English
          arrow-up
          9
          ·
          1 年前

          Mfw I’m checking for null

      • cobysev@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        arrow-down
        1
        ·
        1 年前

        ?:)

      • pogodem0n@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        1 年前

        Holy shit

    • MyNameIsRichard@lemmy.ml
      link
      fedilink
      arrow-up
      5
      ·
      1 年前

      It was called Elvis back when it was a smiley

  • bl4kers@lemmy.ml
    link
    fedilink
    English
    arrow-up
    14
    ·
    1 年前

    I don’t understand this. Small brained users rise up

    • QuazarOmega@lemy.lol
      link
      fedilink
      arrow-up
      13
      ·
      1 年前

      On the left you have Elvis Presley, while on the right there’s the so-called Elvis operator

      • The Cuuuuube@beehaw.org
        link
        fedilink
        English
        arrow-up
        16
        ·
        1 年前

        been programming since 2008. the fuck is an elvis operator?

        • Jerkface (any/all)@lemmy.ca
          link
          fedilink
          English
          arrow-up
          8
          ·
          1 年前

          Been programming since the 80s, ditto.

        • luciferofastora@lemmy.zip
          link
          fedilink
          arrow-up
          4
          ·
          1 年前

          Ternary if?then:else

          • The Cuuuuube@beehaw.org
            link
            fedilink
            English
            arrow-up
            4
            ·
            1 年前

            gotacha. i’ve only ever heard them called ternaries. maybe i’m old. maybe i’m too young. definitely one of the two

            • QuazarOmega@lemy.lol
              link
              fedilink
              arrow-up
              8
              ·
              1 年前

              It specifically refers to this shorthand ?: that works like this:

              $value = $thing_that_could_be_truthy ?: 'fallback value';
              
              # same as
              
              $value = $thing_that_could_be_truthy ? $thing_that_could_be_truthy : 'fallback value';
              

              The condition is also the value if it is truthy

        • dev_null@lemmy.ml
          link
          fedilink
          arrow-up
          3
          ·
          edit-2
          1 年前

          It’s a shorthand for writing this:

          variable = if (input != null) input else default
          

          This is equivalent:

          variable = input ?: default
          

          The answers confusing it with the ternary operator are wrong.

      • AVincentInSpace@pawb.social
        link
        fedilink
        English
        arrow-up
        3
        ·
        1 年前

        why would you call it anything other than the ternary operator

        • dev_null@lemmy.ml
          link
          fedilink
          arrow-up
          3
          ·
          edit-2
          1 年前

          Because it’s not one. Ternary operator is A ? B : C, Elvis operator is A ?: B. The same two characters are involved, but both the syntax and effect is different.

          • AVincentInSpace@pawb.social
            link
            fedilink
            English
            arrow-up
            2
            ·
            1 年前

            The second one isn’t valid syntax in any programming language I’m familiar with. What does it do?

            • dev_null@lemmy.ml
              link
              fedilink
              arrow-up
              4
              ·
              1 年前

              It’s a shorthand for writing this:

              variable = if (input != null) input else default
              

              This is equivalent:

              variable = input ?: default
              
              • AVincentInSpace@pawb.social
                link
                fedilink
                English
                arrow-up
                2
                ·
                edit-2
                1 年前

                Huh. Neat feature.

                • dev_null@lemmy.ml
                  link
                  fedilink
                  arrow-up
                  2
                  ·
                  edit-2
                  1 年前

                  It’s in Kotlin and some other languages. C# has it but there it’s actually A ?? B.

        • QuazarOmega@lemy.lol
          link
          fedilink
          arrow-up
          2
          ·
          1 年前

          Read further down on my other comment to understand, it’s just how the operator looks

  • deathmetal27@lemmy.world
    link
    fedilink
    arrow-up
    13
    ·
    1 年前

    Kotlin user spotted

    • DeprecatedCompatV2@programming.dev
      link
      fedilink
      arrow-up
      3
      ·
      edit-2
      1 年前

      (run { [email protected]?.apply { this.value === true } } == true) ?: if (([email protected] as? Boolean) != true) false else true

    • QuazarOmega@lemy.lol
      link
      fedilink
      arrow-up
      3
      ·
      1 年前

      php too

      …but we don’t talk about php

      • Sleepzy@feddit.itOP
        link
        fedilink
        arrow-up
        2
        ·
        1 年前

        php doesn’t exist, php can’t hurt you

        • tetris11@lemmy.ml
          link
          fedilink
          arrow-up
          3
          ·
          1 年前
          You have absolutely nothing
          <?php
             well hello there again
          ?>
          to worry about. If PHP existed
          we would have sophisticated
          <?php
            I trust that life has
            been treating you well? 
          ?>
          methods of detecting it, and
          it would pose literally no
          <?php
            Don't open the door. It's me.
          ?>
          threat to anyone.
          
          • fxdave@lemmy.ml
            link
            fedilink
            arrow-up
            2
            ·
            edit-2
            1 年前

            aah my favorite template engine, I have seen it so long ago

        • QuazarOmega@lemy.lol
          link
          fedilink
          arrow-up
          1
          ·
          1 年前

          Oh unfortunately these imaginary pains are those which hurt every day

    • silasmariner@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      1 年前

      Nobody’s assuming Groovy these days then 😂

      • chunkystyles@sopuli.xyz
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 年前

        I’ve been working in Jenkins pipeline for a while now.

        Why the fuck is Groovy?

        • silasmariner@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          1 年前

          Well Grails didn’t stick around for long, but Gradle was only available with Groovy for many years before they added Kotlin support.

  • NicKoehler@feddit.it
    link
    fedilink
    arrow-up
    3
    ·
    1 年前

    Same

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

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.

  • 86 users / day
  • 865 users / week
  • 2.08K users / month
  • 6.93K users / 6 months
  • 1 local subscriber
  • 39.5K subscribers
  • 1.94K Posts
  • 39.5K Comments
  • Modlog
  • mods:
  • AgreeableLandscape@lemmy.ml
  • cat_programmer@lemmy.ml
  • BE: 0.19.7
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org