• AVincentInSpace
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 hours 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
      arrow-up
      1
      ·
      10 hours ago

      It’s a shorthand for writing this:

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

      This is equivalent:

      variable = input ?: default