this post was submitted on 08 Dec 2023
623 points (96.6% liked)

Programmer Humor

32042 readers
1366 users here now

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

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 13 points 9 months ago (1 children)

If this was cpp, clang-tidy would tell you “do not use else after return”

I don’t know how null works in swift, but assuming it coerces to bool I’d write

if (a) return a;
return b;
[–] [email protected] 3 points 9 months ago

It's nil, and you can coalesce it with ??