That's interesting. I've had the opposite reaction to those many little decisions: it doesn't matter. Do whichever you like. All of the options are sufficiently readable.
"foo bar"
.split(" ")
.map(&:capitalize)
.join " "
There is really no advantage to not putting parens for the `join` call. Meanwhile, it makes modification a pain as well as makes for some ugly diffs.But as a sibling comment mentioned: just use a linter.
# Does not work
"foo bar"
.split " "
.join " "
There was a proposal to introduce a "pipe" operator at one point which was shot down [0]. It wasn't actually a pipe operator at all and really just an operator that would have made the previous syntax possible (|>, instead of .)[0] https://dev.to/baweaver/ruby-2-7-the-pipeline-operator-1b2d
For calls with some non-block arguments, it's not so clear-cut as "always include parentheses".
Some methods are so prevalent that they almost become part of the language "syntax", even though there's nothing syntactically special about them. For example, you rarely see parentheses used on calls to `attr_accessor` or `private`:
class Cat
attr_accessor :fluffiness
private def plan_world_domination
# TODO
end
end
I think parentheses around `private(def some_method ... end)` would be especially non-idiomatic. Even though passing the result of the `def` expression to the `private` method is exactly what's happening.Another place where it's usual to omit method call parentheses is on embedded DSLs. For example, in RSpec it's uncommon to include parentheses on calls to `describe` or `it`.
describe "RSpec DSL" do
it "looks neater without parentheses" do
# ...
end
end