| 40 columns | |
| >>> Simple bool pattern. |
| if (obj case true) {;} |
| <<< |
| if (obj case true) { |
| ; |
| } |
| >>> Unsplit pattern. |
| if ( obj case 123 || constant ) {} |
| <<< |
| if (obj case 123 || constant) {} |
| >>> Split long expression before case. |
| if (thisIsReallyQuiteAVeryLongVariableName case 1) {;} |
| <<< |
| if (thisIsReallyQuiteAVeryLongVariableName |
| case 1) { |
| ; |
| } |
| >>> Split long case clause before case. |
| if (obj case 123456789012345678901234567890) {;} |
| <<< |
| if (obj |
| case 123456789012345678901234567890) { |
| ; |
| } |
| >>> Case and guard on same line. |
| if (obj case constant when condition) {;} |
| <<< |
| if (obj case constant when condition) { |
| ; |
| } |
| >>> Prefer to split guard before case. |
| if (expression case longConstant when condition) {;} |
| <<< |
| if (expression case longConstant |
| when condition) { |
| ; |
| } |
| >>> Split case and keep guard on same line. |
| if (veryLongExpression case veryLongConstant when cond) {;} |
| <<< |
| if (veryLongExpression |
| case veryLongConstant when cond) { |
| ; |
| } |
| >>> Split case and guard. |
| if (veryLongExpression case veryLongConstant when veryLongCondition) {;} |
| <<< |
| if (veryLongExpression |
| case veryLongConstant |
| when veryLongCondition) { |
| ; |
| } |
| >>> If value splits then case splits. |
| if (veryLongExpression + anotherVeryLongOne case someCase) {;} |
| <<< |
| if (veryLongExpression + |
| anotherVeryLongOne |
| case someCase) { |
| ; |
| } |
| >>> If value splits then case splits but guard doesn't have to. |
| if (veryLongExpression + anotherVeryLongOne case someCase when true) {;} |
| <<< |
| if (veryLongExpression + |
| anotherVeryLongOne |
| case someCase when true) { |
| ; |
| } |
| >>> Split in block-format pattern does not force case to split. |
| if (obj case const [veryLongElement,veryLongElement,veryLongElement,]) {;} |
| <<< |
| if (obj case const [ |
| veryLongElement, |
| veryLongElement, |
| veryLongElement, |
| ]) { |
| ; |
| } |
| >>> Split in block-format guard condition forces split at `when`. |
| if (obj case constant when [veryLongElement,veryLongElement,veryLongElement,]) {;} |
| <<< |
| if (obj case constant |
| when [ |
| veryLongElement, |
| veryLongElement, |
| veryLongElement, |
| ]) { |
| ; |
| } |
| >>> Block-format split in pattern but not guard. |
| if (obj |
| case const [veryLongElement,veryLongElement,veryLongElement,] |
| when veryLongConstant || longConstant) {;} |
| <<< |
| if (obj |
| case const [ |
| veryLongElement, |
| veryLongElement, |
| veryLongElement, |
| ] |
| when veryLongConstant || |
| longConstant) { |
| ; |
| } |
| >>> Block-format split in guard but not pattern. |
| if (obj |
| case veryLongConstant || longConstant when |
| [veryLongElement,veryLongElement,veryLongElement,]) {;} |
| <<< |
| if (obj |
| case veryLongConstant || |
| longConstant |
| when [ |
| veryLongElement, |
| veryLongElement, |
| veryLongElement, |
| ]) { |
| ; |
| } |
| >>> Block-format splits in both pattern and guard. |
| if (obj case const [veryLongElement,veryLongElement,veryLongElement,] when |
| [veryLongElement,veryLongElement,veryLongElement,]) {;} |
| <<< |
| if (obj |
| case const [ |
| veryLongElement, |
| veryLongElement, |
| veryLongElement, |
| ] |
| when [ |
| veryLongElement, |
| veryLongElement, |
| veryLongElement, |
| ]) { |
| ; |
| } |
| >>> If pattern splits then case splits. |
| if (obj case veryLongConstant || longConstant) {;} |
| <<< |
| if (obj |
| case veryLongConstant || |
| longConstant) { |
| ; |
| } |
| >>> If guard condition block splits then guard splits. |
| if (obj case constant when veryLongExpression + anotherOne) {;} |
| <<< |
| if (obj case constant |
| when veryLongExpression + |
| anotherOne) { |
| ; |
| } |