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

Prefer trailing dots over leading dots #2

Merged
merged 1 commit into from
May 25, 2017
Merged
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
25 changes: 4 additions & 21 deletions ruby.md
Original file line number Diff line number Diff line change
Expand Up @@ -521,28 +521,11 @@ style guide.
```

* <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&mdash;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 @@ -553,7 +536,7 @@ style guide.
four
```

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

* <a name="no-double-indent"></a>
Expand Down