Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Favor trailing dot for multi-line chaining of methods #1

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 3 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,28 +445,11 @@ Translations of the guide are available in the following languages:
```

* <a name="consistent-multi-line-chains"></a>
Adopt a consistent multi-line method chaining style. There are two
popular styles in the Ruby community, both of which are considered
good - leading `.` (Option A) and trailing `.` (Option B).
When continuing a chained method invocation on another line,
include the `.` on the first line to indicate that the expression
continues.
<sup>[[link](#consistent-multi-line-chains)]</sup>

* **(Option A)** When continuing a chained method invocation on
another line keep the `.` on the second line.

```Ruby
# bad - need to consult first line to understand second line
one.two.three.
four

# good - it's immediately clear what's going on the second line
one.two.three
.four
```

* **(Option B)** When continuing a chained method invocation on another line,
include the `.` on the first line to indicate that the
expression continues.

```Ruby
# bad - need to read ahead to the second line to know that the chain continues
one.two.three
Expand All @@ -477,9 +460,6 @@ Translations of the guide are available in the following languages:
four
```

A discussion on the merits of both alternative styles can be found
[here](https://github.com/bbatsov/ruby-style-guide/pull/176).

* <a name="no-double-indent"></a>
Align the parameters of a method call if they span more than one
line. When aligning parameters is not appropriate due to line-length
Expand Down