233

(Shamelessly stolen from reddit)

you are viewing a single comment's thread
view the rest of the comments
[-] MightBeFluffy@pawb.social 25 points 2 weeks ago* (last edited 2 weeks ago)

A ternary is a short hand to assign a value based on a true/false statement

let a; if(isTtrue) a=2 else a=9

Becomes

let a = (isTrue) ? 2 : 9

[-] tja@sh.itjust.works 7 points 2 weeks ago* (last edited 2 weeks 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

[-] 48954246@lemmy.world 3 points 2 weeks ago* (last edited 2 weeks ago)

I like the python way as it reads more naturally

a = 2 if isTrue else 9
this post was submitted on 17 Jul 2025
233 points (87.0% liked)

Programmer Humor

25448 readers
925 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS