99

Made with KolourPaint and screenshots from Kate (with the GitHub theme).

you are viewing a single comment's thread
view the rest of the comments
[-] ThirdConsul@lemmy.ml 5 points 10 months ago

To be honest I always disliked variable declaration without value assignment, so to me both options suck. :)

[-] notarobot@lemm.ee 5 points 10 months ago* (last edited 10 months ago)

What about

Let ret: Number
If (someCondition) {
    <a lot of expensive calculations>
    ret = resultOfOperations
} else {
    <a lot of other different expensive operations>
    ret = resultOfOtherOperations
}
return ret

You can't declare ret inside the brackets

[-] ThirdConsul@lemmy.ml 4 points 10 months ago
let ret = someCondition ? expensiveOperation() : otherOperation() 

?

[-] notarobot@lemm.ee 2 points 10 months ago

Yeah. That works.

load more comments (5 replies)
load more comments (10 replies)
this post was submitted on 19 Jun 2025
99 points (87.2% liked)

Programmer Humor

41902 readers
2 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 years ago
MODERATORS