Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



I 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


Hum... 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.


I 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.


Ruby has this. Can be surprising to read code ... "Wait.. What? Oh ok."




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: