| ▲ | XorNot 5 hours ago | |
But it would be a subvariant of a much more common pattern in code - destructuring which is quite noisy now but could just be:
Which would be conventional for the whole thing, and the check would be for an empty type after rest.I usually wind up using something like the samber/lo library to reduce the noise here. You wind up doing this all the time. | ||
| ▲ | kbolino 5 hours ago | parent [-] | |
I must disagree. Destructuring is nifty, but it is almost completely unrelated. The second value in any of the builtin two-value assignment forms is invariant on the type or size of RHS; it's always a boolean, and its meaning relates to the "kind" of RHS, not the exact type:
This new operation would be similar:
For all of these cases, ok being true indicates that the other value is safe to use. | ||