Beehaw
  • Communities
  • Create Post
  • search
    Search
  • Login
  • Sign Up
Sleepzy ( Sleepzy@feddit.it )  to Programmer Humor@lemmy.ml · 2 years ago

Elvis

feddit.it

message-square
15
link
fedilink
90

Elvis

feddit.it

Sleepzy ( Sleepzy@feddit.it )  to Programmer Humor@lemmy.ml · 2 years ago
message-square
15
link
fedilink
  • The Cuuuuube ( Cube6392@beehaw.org ) 
    link
    fedilink
    English
    arrow-up
    16
    ·
    2 years ago

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

    • Jerkface (any/all) ( jerkface@lemmy.ca ) 
      link
      fedilink
      English
      arrow-up
      8
      ·
      edit-2
      9 months ago

      Removed by mod

    • luciferofastora ( luciferofastora@lemmy.zip ) 
      link
      fedilink
      arrow-up
      4
      ·
      2 years ago

      Ternary if?then:else

      • The Cuuuuube ( Cube6392@beehaw.org ) 
        link
        fedilink
        English
        arrow-up
        4
        ·
        2 years 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 ( QuazarOmega@lemy.lol ) 
          link
          fedilink
          arrow-up
          8
          ·
          2 years 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 ( dev_null@lemmy.ml ) 
      link
      fedilink
      arrow-up
      3
      ·
      2 years 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.

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.

  • 1 user / day
  • 41 users / week
  • 300 users / month
  • 1.73K users / 6 months
  • 871 local subscribers
  • 43.7K subscribers
  • 1.25K Posts
  • 10.3K Comments
  • Modlog
  • mods:
  • AgreeableLandscape ( AgreeableLandscape@lemmy.ml ) 
  • cat_programmer ( cat_programmer@lemmy.ml ) 
  • BE: 0.19.15
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code