Neo Mujico
  • 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
5
fedilink
1

know the features of your language

lemmy.world

jroid8@lemmy.world to Programmer Humor@lemmy.ml · 2 years ago
message-square
5
fedilink
alert-triangle
You must log in or register to comment.
  • zero_gravitas@aussie.zone
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 years ago

    There’s a nice list of this feature by language on the Wikipedia page for anyone interested: https://en.wikipedia.org/wiki/Null_coalescing_operator#Examples_by_languages

  • Kogasa@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    People ITT hating on null coalescing operators need to touch grass. Null coalescing and null conditional (string?.Trim()) are immensely useful and quite readable. One only has to be remotely conscious of edge cases where they can impair readability, which is true of every syntax feature

  • sndrtj@feddit.nl
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    a.unwrap_or(b)

  • maegul (he/they)@lemmy.ml
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    2 years ago

    Python, checking in …

    return (a or b)
    

    Parentheses aren’t necessary, I just prefer them for readability.

    See python documentation on boolean operators for reference. Short story is a or b is an expression that evaluates to a if a is “truthy” else b. “Falsy” is empty strings/containers, 0 and None.

  • PoastRotato@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    My coworker flips his shit every time I include a ternary operator in a PR. He also insists on refactoring any block of code longer than two lines into its own function, even when it’s only used once.

    He is not well liked.

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.

  • 9 users / day
  • 17 users / week
  • 89 users / month
  • 376 users / 6 months
  • 0 local subscribers
  • 36.9K subscribers
  • 1K Posts
  • 3.58K Comments
  • Modlog
  • mods:
  • AgreeableLandscape@lemmy.ml
  • cat_programmer@lemmy.ml
  • BE: 0.19.8
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org