great example of the difference between Some(0) and None
getFrog@piefed.social 1 day ago
Unironically a great example for explaining the difference between 0 and null
webpack@ani.social 1 day ago
ChaoticNeutralCzech@feddit.org 1 day ago
There are different kinds of non-number “values” for numeric variables. Is this
∞,Overflow,NaNorN/A?getFrog@piefed.social 1 day ago
I’m a JavaScript girl, I only know about null and undefined. But my guess would be
N/A, just by method of elimination?∞: They said the N-word, but if we ask “did they say the N-word yesterday?” and go back a day if the answer is no, we will be iterating forever.
Overflow: They said the N-word sometime before Jan 1st 1970.
NaN: Days since the last time they said the N-word: “yes”BlackRoseAmongThorns@slrpnk.net 22 hours ago
All these special values are from the spec for floating point numbers, integers don’t have them, in JS specifically all numbers are floats.
An
Option<int>does a good of showing intent.ChaoticNeutralCzech@feddit.org 23 hours ago
There are actually two interpretations of
N/A:N/A(not available): There is lost media so it can’t be evaluated.N/A(not applicable): The show is in sign language so evaluating that is outside the scope of this string-matching program.
Meanwhile,
undefinedseems to mean the value has not yet been evaluated. Maybenullis really the best.elephantium@lemmy.world 16 hours ago
🎵 I’m a Java girl in a Java world…
Sadly, JavaScript breaks the cadence :(
NikkiDimes@lemmy.world 19 hours ago
Whaaat Javascript is famously known for being extremely weird with NaN values lol
humorlessrepost@lemmy.world 15 hours ago
Yeah but we almost never use them intentionally. In almost any project, NaN only happens if there’s a bug. The others are regularly on purpose.
luciferofastora@feddit.org 22 hours ago
I mean,
NaNimplies there exists some value, it’s just not a numerical one.nulldays there is none at all.
starik@lemmy.zip 1 day ago
Sadly, it’s not. The other three churn out books riddled with the n-word daily.