Commit b6c2f66
authored
Topics > Inputs: Clarify the purpose of handling nullables in JS. (#402)
* Topics > Inputs: Clarify the purpose of handling nullables in JS.
- The narrative about "using an or operator" appeared to have missed the
point about the purpose. In fact, there's nothing special about the
"or" (double-pipe || ) logical operator in the JS expression when it
comes to checking the actual underlying type of a union-typed value.
The problem is twofold:
1. The underlying issue is not that the *value* may "contain one of the
exclusive input values"; it's their *type* difference that causes
incompatibilities.
2. For this, the solution is to *handle* the possible types, and it
only happens that in this particular example, a standard "default"
syntax with the shortcircuiting boolean operator would do.
Therefore the content is revised to explicitly warn of the possibility
of encountering the "wrong" type, and give a better rationale of using
the || syntax in the expression.
- Minor normalization of blocks. Use three backticks when these blocks
are siblings without nesting.
* Topics > Inputs: Further clarify how || works in the JS expression
- No need to mention "any other" falsy value
- Quantify the word "expression" to mean the expression as a whole, not
any of its parts that may also stand as an expression.
* Topics > Inputs: Remove the mentions of "truthy" and "falsy".
These terms are too specific to JS, and likely a distraction from the
main point.1 parent 1ecadfc commit b6c2f66
1 file changed
+25
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
| 245 | + | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
261 | 262 | | |
262 | 263 | | |
263 | 264 | | |
| |||
268 | 269 | | |
269 | 270 | | |
270 | 271 | | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
275 | 276 | | |
276 | 277 | | |
277 | 278 | | |
278 | | - | |
| 279 | + | |
279 | 280 | | |
280 | 281 | | |
281 | | - | |
| 282 | + | |
282 | 283 | | |
283 | 284 | | |
284 | 285 | | |
285 | 286 | | |
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
293 | 301 | | |
294 | 302 | | |
295 | 303 | | |
| |||
0 commit comments