3 ms·
Unless is hugely valuable to me, "do x unless y" is great when x should happen in almost all cases. It avoids the noise of if statements, I really miss it in l
by jrumbut 6y ago
Unless is hugely valuable to me, "do x unless y" is great when x should happen in almost all cases.
It avoids the noise of if statements, I really miss it in languages that don't have it.
- jbergknoff 6y agoI have a really hard time parsing `unless`. Whenever I encounter it in Ruby or CoffeeScript code, it takes me 10-30 seconds to stop and understand what's happening with the code. Generally, postfix conditionals are a bad idea because they are garden-path sentences [1] by design. Glad you find them valuable, but IMO they epitomize what many other comments in this thread have said about CoffeeScript's poor readability. [1] https://en.wikipedia.org/wiki/Garden-path_sentence https://en.wikipedia.org/wiki/Garden-path_sentence
- st1ck 6y agoI don't see anything common in structure between postfix `unless` and examples of garden-path sentences, which seem to be based on word ambiguity. Nothing is ambiguous in e.g. `print(x) unless x != 0`. Although admittedly without syntax highlighting, conditionality it's less obvious.