bbatsov/ruby-style-guide — Issue #68: Styles for method calls
Author: wicz
Created: 2012-01-19 13:57:47+00:00
State: open

I'd like to suggest the following styles regarding to method calls.

Given the method:

```ruby
def say_hi(name, surname = nil)
"Hi #{name} #{surname}!"
end
```

* Calling with two or more parameters should always use parens:

```ruby
# good
say_hi("John", "Doe")

# bad
say_hi "John", "Doe"
```

* Calling with one parameter can omit parens as longs as it isn't consuming the return value:

```ruby
# good
say_hi "John"

# good
output = say_hi("John")

# bad
output = say_hi "John"
```

* The same rules apply to nested calls:

```ruby
# good
pretty_print say_hi("John")

# bad
pretty_print say_hi "John"

# good
pretty_print say_hi("John", "Doe")

# bad
pretty_print say_hi "John", "Doe"
```

Please feel free to give your impressions. And congrats for the great work!