4 ms·
I’m not clear on what the point of your response is, the comment you responded to is making an often overlooked point that certain subtleties in how languages i
by fieldcny 3y ago
I’m not clear on what the point of your response is, the comment you responded to is making an often overlooked point that certain subtleties in how languages implement constructs can create sharp edges, one of those being the null coalescing operator.
- smegsicle 3y agothe point is that lua didn't make the mistake of false 'empty' values, so that particular sharp edge is absent
- DemocracyFTW2 3y agoThe edge of "false 'empty' values" is absent in Lua, indeed, but the `a = b or c`, more often used in the form `b = b or c`, has, in Lua, still the problem that it will evaluate to `c` if `b` is `nil` and when b is `false` which may or may not be what one wants—and often one wants it not. The idiom is commonly used to assign a proper value to a variable that has not been set to an explicit value, i.e. a variable that is `nil`. The assignment `b = b or true` will set `b` to `true` if it was `nil` or `false`; assuming allowable values for `b` are `true` and `false` and the default is `true`, `b` will then never keep the value of `false` and always be set to `true`.