schoenwolf-schroeder
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
@Sleepzy@feddit.it to Programmer Humor@lemmy.ml • 6 months ago

Elvis

feddit.it

message-square
32
fedilink
1

Elvis

feddit.it

@Sleepzy@feddit.it to Programmer Humor@lemmy.ml • 6 months ago
message-square
32
fedilink
alert-triangle
You must log in or register to comment.
  • propter_hog [mirror/your pronouns]
    link
    fedilink
    English
    0•6 months ago

    I will never call this the “Elvis” operator. That’s as dumb as dog shit. It’s called the ternary operator.

    • @Boomkop3@reddthat.com
      link
      fedilink
      0•6 months ago

      I had to go into the comments to find that out. Is this like an old people thing?

  • @Blue_Morpho@lemmy.world
    link
    fedilink
    0•6 months ago

    I never heard it called the Elvis operator! Thanks!

    • @MyNameIsRichard@lemmy.ml
      link
      fedilink
      0•6 months ago

      It was called Elvis back when it was a smiley

    • The Ramen Dutchman
      link
      fedilink
      0•6 months ago

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

      • cobysev
        link
        fedilink
        English
        0•6 months ago

        ?:)

      • @disguy_ovahea@lemmy.world
        link
        fedilink
        0•6 months ago

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

        Elvis lip

        • Dwemthy (he/him)
          link
          fedilink
          English
          0•6 months ago

          Mfw I’m checking for null

  • @NicKoehler@feddit.it
    link
    fedilink
    0•6 months ago

    Same

  • @deathmetal27@lemmy.world
    link
    fedilink
    0•6 months ago

    Kotlin user spotted

    • @DeprecatedCompatV2@programming.dev
      link
      fedilink
      0•
      edit-2
      6 months ago

      (run { this@comment.parent?.apply { this.value === true } } == true) ?: if ((this@comment.value as? Boolean) != true) false else true

    • @QuazarOmega@lemy.lol
      link
      fedilink
      0•6 months ago

      php too

      …but we don’t talk about php

      • @Sleepzy@feddit.itOP
        link
        fedilink
        0•6 months ago

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

        • @tetris11@lemmy.ml
          link
          fedilink
          0•6 months ago
          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
            0•
            edit-2
            6 months ago

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

    • @silasmariner@programming.dev
      link
      fedilink
      0•6 months ago

      Nobody’s assuming Groovy these days then 😂

      • @chunkystyles@sopuli.xyz
        link
        fedilink
        English
        0•6 months ago

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

        Why the fuck is Groovy?

  • @bl4kers@lemmy.ml
    link
    fedilink
    English
    0•6 months ago

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

    • @QuazarOmega@lemy.lol
      link
      fedilink
      0•6 months ago

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

      • @AVincentInSpace@pawb.social
        link
        fedilink
        English
        0•6 months ago

        why would you call it anything other than the ternary operator

        • @QuazarOmega@lemy.lol
          link
          fedilink
          0•6 months ago

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

        • @dev_null@lemmy.ml
          link
          fedilink
          0•
          edit-2
          6 months ago

          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
            0•6 months ago

            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
              0•6 months ago

              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
                0•
                edit-2
                6 months ago

                Huh. Neat feature. That’s in C# I assume?

                • @dev_null@lemmy.ml
                  link
                  fedilink
                  0•
                  edit-2
                  6 months ago

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

      • The Cuuuuube
        link
        fedilink
        English
        0•6 months ago

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

        • @luciferofastora@lemmy.zip
          link
          fedilink
          0•6 months ago

          Ternary if?then:else

          • The Cuuuuube
            link
            fedilink
            English
            0•6 months ago

            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
              0•6 months ago

              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
          0•
          edit-2
          6 months ago

          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.

        • Jerkface (any/all)
          link
          fedilink
          English
          0•6 months ago

          Been programming since the 80s, ditto.

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.
  • 20 users / day
  • 39 users / week
  • 147 users / month
  • 1.62K users / 6 months
  • 35.6K subscribers
  • 1.23K Posts
  • 17.6K Comments
  • Modlog
  • mods:
  • @AgreeableLandscape@lemmy.ml
  • @cat_programmer@lemmy.ml
  • BE: 0.19.3
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org