Quote:
Originally Posted by blackize5
Can you clarify? No style guide I've ever seen has suggested that
is bad. Unless your argument is that this can be refactored to something like
in which case I'd argue you'll still pretty often need to use the former style because of line length style guide considerations (especially when there is an else clause)
+1 to RubyMine though. I use RubyMine with the vim plugin and love it.
it wasn't a style comment in the sense of the ruby style guide.
if you are writing block level if else code, you are thinking procedurally, and you aren't using ruby to its full capacity, even though ruby supports that style of programming too.
concretely: use the ternary operator with short expressions, or use the post-expression if, as you did. but ofc methods with "or" and "and" in their names are a code smell too.
this rule forces you to aggressively name your concepts, even small ones. you'll think harder about what you're doing, and your code will be more readable, and have one level less indentation.
essentially, multiline, block style if else statements (aside from being physically ugly) are like junk drawers for cluttered thoughts. nesting them should be punishable by death.