3 ms·
Perl caught me off guard with this. We apparently had a programmer who liked to write Statement unless x; This did not make left to write code scanning me h
by acomjean 4y ago
Perl caught me off guard with this. We apparently had a programmer who liked to write
Statement unless x;
This did not make left to write code scanning me happy.
- zimpenfish 4y agoI have fractionally more sympathy for the post-conditional `if` - `statement if x;` - because at least then you're not trying to invert things at the end of a sentence. Only fractionally because I hate all post-conditionals with a passion. They're the garden paths[1] of coding. [1] https://en.wikipedia.org/wiki/Garden-path_sentence https://en.wikipedia.org/wiki/Garden-path_sentence
- marcosdumay 4y agoHum... The only thing that changes is that the exception comes on its negated form. It doesn't make code scanning any harder, or interpreting it any more convoluted. Personally, I do hate both of those (including the Python's ternary operator). But there is something with the bashism it shares, of `do_it() or die "trying"` that looks quite nice.
- sn41 4y agoRuby has this. Can be surprising to read code ... "Wait.. What? Oh ok."
- Beltalowda 4y agoI like to do that in Ruby. It just reads so natural: $x = foo() unless $y > 10 As with any language feature, you can over-use it, but in general once I was used to it I missed it in every other programming language.