From a13f1e9137caf66486ae86f5398c7ff31c872b51 Mon Sep 17 00:00:00 2001 From: Amiel Martin Date: Wed, 24 May 2017 11:34:22 -0800 Subject: [PATCH] Opt for Option B of consistent-multi-line-chains That is, trailing dots over leading dots --- ruby.md | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/ruby.md b/ruby.md index 26963ec..d8fdae7 100644 --- a/ruby.md +++ b/ruby.md @@ -521,28 +521,11 @@ style guide. ``` * - 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. [[link](#consistent-multi-line-chains)] - * **(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 @@ -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). *