3 ms·
(speaking for myself only): I find the ?: syntax clearer... probably because I've known it for so many years. It's the doing several things at once that, for me
by hyp0 12y ago
(speaking for myself only): I find the ?: syntax clearer... probably because I've known it for so many years. It's the doing several things at once that, for me, makes it unclear.
Of your examples, I find the very last one the clearest. Arguably, it's a hack, because it assigns values twice to x - but it feels like the syntax embodies the semantic truth of y==0 being an exception. A pattern matching solution (with a specific and then a general rule) would also embody this, but to me, having the general rule first, with a following exception, seems more intuitive.
Disclaimer: "intuitive" is all very subjective, and it's certainly possible that with experience, my intuition could change. But for better or worse, the above is my opinion today!
PS: I do think your first example is cool, neat and clever. I understand and feel that aspect of the appeal.