File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 840840arr.each { |elem | puts elem }
841841```
842842
843- * Prefer ` {...} ` over ` do...end ` for single-line blocks. Avoid using
844- ` {...} ` for multi-line blocks (multiline chaining is always
845- ugly). Always use ` do...end ` for "control flow" and "method
846- definitions" (e.g. in Rakefiles and certain DSLs). Avoid ` do...end `
847- when chaining.
843+ * Prefer ` {...} ` over ` do...end ` for single-line blocks. Avoid using
844+ ` {...} ` for multi-line blocks. Always use ` do...end ` for "control flow" and "method
845+ definitions" (e.g. in Rakefiles and certain DSLs).
848846 <a name =" squiggly-braces " ></a ><sup >[[ link] ( #squiggly-braces )] </sup >
849847 * <a href =" https://docs.rubocop.org/rubocop/cops_style.html#styleblockdelimiters " >RuboCop rule: Style/BlockDelimiters</a >
850848
@@ -858,20 +856,8 @@ names.each { |name| puts name }
858856names.each do |name |
859857 puts name
860858end
861-
862- # good
863- names.select { |name | name.start_with?(" S" ) }.map { |name | name.upcase }
864-
865- # bad
866- names.select do |name |
867- name.start_with?(" S" )
868- end .map { |name | name.upcase }
869859```
870860
871- * Some will argue that multiline chaining would look OK with the use of ` {...} ` ,
872- but they should ask themselves: is this code really readable and can't the block's
873- contents be extracted into nifty methods?
874-
875861* Avoid ` return ` where not required.
876862 <a name =" avoid-return " ></a ><sup >[[ link] ( #avoid-return )] </sup >
877863 * <a href =" https://docs.rubocop.org/rubocop/cops_style.html#styleredundantreturn " >RuboCop rule: Style/RedundantReturn</a >
You can’t perform that action at this time.
0 commit comments