4 ms·
I really dislike post-statement ifs, like "do_something() if condition?". They seem to be used particularly often in Ruby. I don't know how dependent clauses ("
by silentbicycle 16y ago
I really dislike post-statement ifs, like "do_something() if condition?". They seem to be used particularly often in Ruby. I don't know how dependent clauses ("if x then y" vs. "y if x") work in Japanese, but Ruby coming from Japan may be a factor.
"if (3 == x)" doesn't bother me so much, I tend to think of it like unification in Prolog.
- mdaniel 16y agoI got into the habit of writing literals first from being bitten one too many times by the (absolutely insane!) semantic difference between "=" and "==". In my day job (working with Java) it's less of a problem, but I switch languages so much in my spare time that it has served me well.
- prakashk 16y agopost-statement ifs, ... used particularly often in Ruby. ... Ruby coming from Japan may be a factor. I think Ruby borrowed them from Perl's Statement modifiers (http://perldoc.perl.org/perlsyn.html#Statement-Modifiers http://perldoc.perl.org/perlsyn.html#Statement-Modifiers). I like them and use them when I want the focus to be on the body rather than the conditional.
- hasenj 16y agoJapanese conditionals come (AFAIK) before statements. They can come after statements, just like in English, "Tell me if you see him". I don't use Ruby but I actually like this idea. Often when reading code, I'm looking for what's being done, not the condition under which it's done. I only look for the condition after I've found the statement.
- deleted 16y ago[deleted]