File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,45 @@ You can generate a PDF or an HTML copy of this guide using
140140 end
141141 ` ` `
142142
143+ * put multi when conditions on separate lines
144+
145+ ` ` ` Ruby
146+ # good
147+
148+ case token
149+ when :star_op
150+ stack.pop * stack.pop
151+ when :slash_op
152+ stack.pop / stack.pop
153+ when :minus_op
154+ also_calculate_that
155+ stack.pop - stack.pop
156+ when :plus_op,
157+ :plus_plus_op
158+ stack.pop + stack.pop
159+ when :int_literal
160+ token.value
161+ end
162+ ` ` `
163+
164+ which reads better than
165+
166+ ` ` ` Ruby
167+ # bad
168+
169+ case token
170+ when :star_op
171+ stack.pop * stack.pop
172+ when :plus_op, :plus_plus_op
173+ stack.pop + stack.pop
174+ when :int_literal, :str_literal, :str_interpolated
175+ token.value
176+ end
177+ ` ` `
178+
179+ Where the ' bad' example also has the issue of cause the entire when line to diff when one of the conditions is changed or updated
180+
181+
143182* Use empty lines between ` def` s and to break up a method into logical
144183 paragraphs.
145184
You can’t perform that action at this time.
0 commit comments