this post was submitted on 08 Dec 2023
622 points (96.4% liked)

Programmer Humor

32561 readers
391 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
[–] shalva97@lemmy.world 6 points 11 months ago (2 children)
[–] Spzi@lemm.ee 33 points 11 months ago (1 children)

Then null will be returned, as the value of b.

[–] 15liam20@lemmy.world 1 points 11 months ago (1 children)
[–] merthyr1831@lemmy.world 13 points 11 months ago

Normally the purpose of a block of code like this is to provide a fallback hardcoded value if the dynamic value from your API or whatever is null. Like, setting a default title for a page of a notes app if the user didnt set a title themselves etc.

So, b is very likely to be a never-null, hardcoded value.

This code can still be valid and return null if b is null too, as the other person said.