(Shamelessly stolen from reddit)

    • @[email protected]
      link
      fedilink
      English
      3910 days ago

      “Ternary operator” means “operator that takes three things”, like unary and binary operators take one and two things.

      In C there is an operator for conditional expressions (an ‘if’ that you can put inside expressions) and it looks like this condition ? trueBranch : falseBranch. It takes three expressions, so it’s a ternary operator.

      Except it’s the only ternary operator in C (and most languages, if they have one at all), so instead of calling it something like “conditional operator”, they just call it “the ternary operator”

      • TJA!
        link
        fedilink
        7
        edit-2
        10 days ago

        I really like the way kotlin is doing it. The readability of the first one and still a direct assignment.

        var a = if (isTrue) 2 else 9

        • @[email protected]
          link
          fedilink
          English
          18 days ago

          Well if you make me actually explain it, I’m going to sound like an asshole; the joke is so obvious and low-level and the type of humor so uninspired that I figure they must be a little… you know, dumb.

          • @[email protected]
            link
            fedilink
            14 days ago

            Well if you make me actually explain it, I’m going to sound like an asshole

            Too late muchacho… you’re already giving real big superiority vibes here

          • LenaOP
            link
            fedilink
            English
            28 days ago

            It’s not the best joke I’ve seen, but I wouldn’t call it dumb. To each their own, I guess. Jokes are subjective.