diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index f14d1000..f76fb1e9 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -840,11 +840,9 @@ end arr.each { |elem| puts elem } ``` -* Prefer `{...}` over `do...end` for single-line blocks. Avoid using - `{...}` for multi-line blocks (multiline chaining is always - ugly). Always use `do...end` for "control flow" and "method - definitions" (e.g. in Rakefiles and certain DSLs). Avoid `do...end` - when chaining. +* Prefer `{...}` over `do...end` for single-line blocks. Avoid using + `{...}` for multi-line blocks. Always use `do...end` for "control flow" and "method + definitions" (e.g. in Rakefiles and certain DSLs). [[link](#squiggly-braces)] * RuboCop rule: Style/BlockDelimiters @@ -858,20 +856,8 @@ names.each { |name| puts name } names.each do |name| puts name end - -# good -names.select { |name| name.start_with?("S") }.map { |name| name.upcase } - -# bad -names.select do |name| - name.start_with?("S") -end.map { |name| name.upcase } ``` -* Some will argue that multiline chaining would look OK with the use of `{...}`, - but they should ask themselves: is this code really readable and can't the block's - contents be extracted into nifty methods? - * Avoid `return` where not required. [[link](#avoid-return)] * RuboCop rule: Style/RedundantReturn