diff --git a/README.md b/README.md index 35f1b9c60..df1ffde0b 100644 --- a/README.md +++ b/README.md @@ -140,43 +140,52 @@ You can generate a PDF or an HTML copy of this guide using end ``` -* put multi when conditions on separate lines +* put multiple when conditions on separate lines +particularly where the conditions form long, complicated lines ```Ruby # good case token - when :star_op - stack.pop * stack.pop - when :slash_op - stack.pop / stack.pop - when :minus_op - also_calculate_that - stack.pop - stack.pop - when :plus_op, - :plus_plus_op - stack.pop + stack.pop - when :int_literal - token.value - end + when :star_op + stack.pop * stack.pop + when :slash_op + stack.pop / stack.pop + when :minus_op, :plus_op + also_calculate_that + stack.pop - stack.pop + when MyModule::SomeDomain::BETA_USERS, + MyModule::SomeDomain::INTERNAL_RELEASE + stack.pop + stack.pop + when :int_literal, + :some_complicate_explicit_name, + :graduate_borrowers_with_arms, + :str_interpolated + token.value + end ``` - which reads better than + Though better control of primary domain references should be exercised, this style offers a solution for some 'in the wild' situations. It reads better than: ```Ruby # bad case token - when :star_op - stack.pop * stack.pop - when :plus_op, :plus_plus_op - stack.pop + stack.pop - when :int_literal, :str_literal, :str_interpolated - token.value - end + when :star_op + stack.pop * stack.pop + when :slash_op + stack.pop / stack.pop + when :minus_op, :plus_op + also_calculate_that + stack.pop - stack.pop + when MyModule::SomeDomain::BETA_USERS, MyModule::SomeDomain::INTERNAL_RELEASE + stack.pop + stack.pop + when :int_literal, :some_complicate_explicit_name, :graduate_borrowers_with_arms, :str_interpolated + token.value + end ``` - 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 + The 'bad' example also has the issue of cause the entire when line to diff when one of the conditions is changed or updated * Use empty lines between `def`s and to break up a method into logical