Skip to content

Commit 458e30a

Browse files
author
Bozhidar Batsov
committed
[rubocop#169 rubocop#176] Acknowledge trailing . as a good style as well
1 parent d78c40c commit 458e30a

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

README.md

+25-9
Original file line numberDiff line numberDiff line change
@@ -403,17 +403,33 @@ Translations of the guide are available in the following languages:
403403
' and second part of the long string'
404404
```
405405

406-
* When continuing a chained method invocation on another line keep the `.` on the second line.
406+
* Adopt a consistent multi-line method chaining style. There are two
407+
popular styles in the Ruby community, both of which are considered
408+
good - leading `.` and trailing `.`.
407409

408-
```Ruby
409-
# bad - need to consult first line to understand second line
410-
one.two.three.
411-
four
410+
* When continuing a chained method invocation on another line keep the `.` on the second line.
412411

413-
# good - it's immediately clear what's going on the second line
414-
one.two.three
415-
.four
416-
```
412+
```Ruby
413+
# bad - need to consult first line to understand second line
414+
one.two.three.
415+
four
416+
417+
# good - it's immediately clear what's going on the second line
418+
one.two.three
419+
.four
420+
```
421+
422+
* When continuing a chained method invocation on another line, include the `.` on the first line to indicate that the expression continues.
423+
424+
```Ruby
425+
# bad - need to read ahead to the second line to know that the chain continues
426+
one.two.three
427+
.four
428+
429+
# good - it's immediately clear that the expression continues beyond the first line
430+
one.two.three.
431+
four
432+
```
417433

418434
* Align the parameters of a method call if they span more than one
419435
line. When aligning parameters is not appropriate due to line-length

0 commit comments

Comments
 (0)