Lena@gregtech.eu to Programmer Humor@programming.devEnglish · 2 days agoPerfect relationshipgregtech.euimagemessage-square13fedilinkarrow-up1250arrow-down135file-text
arrow-up1215arrow-down1imagePerfect relationshipgregtech.euLena@gregtech.eu to Programmer Humor@programming.devEnglish · 2 days agomessage-square13fedilinkfile-text
minus-squareMightBeFluffy@pawb.sociallinkfedilinkEnglisharrow-up23·2 days agoA ternary is a short hand to assign a value based on a true/false statement let a; it(isTtrue) a = 2 else a=9 Becomes let a = (isTrue) ? 2 : 9
minus-squareTJA!@sh.itjust.workslinkfedilinkarrow-up6·edit-22 days agoI 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
minus-square48954246@lemmy.worldlinkfedilinkEnglisharrow-up3·edit-21 day agoI like the python way as it reads more naturally a = 2 if isTrue else 9
A ternary is a short hand to assign a value based on a true/false statement
let a; it(isTtrue) a = 2 else a=9
Becomes
let a = (isTrue) ? 2 : 9
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
I like the python way as it reads more naturally
a = 2 if isTrue else 9