blob: 0598439875ffa2d1e0b1b51f0eb857da58fe4062 [file] [log] [blame]
40 columns |
>>> Basic list patterns.
switch (obj) {
case [ ] :
case < int > [ ] :
case [ 2 ] :
case [ 2 , ] :
case [ 2 , 3 ] :
ok;
}
<<<
switch (obj) {
case []:
case <int>[]:
case [2]:
case [2]:
case [2, 3]:
ok;
}
>>> Unsplit list.
if (obj case [1, ...var x, 3]) {;}
<<<
if (obj case [1, ...var x, 3]) {
;
}
>>> If it splits anywhere in the list, it splits at every element.
if (obj case [first,second,third,fourth]) {;}
<<<
if (obj case [
first,
second,
third,
fourth,
]) {
;
}
>>> Unsplit short list even with a comma.
if (obj case [1,]) {;}
<<<
if (obj case [1]) {
;
}
>>> Nested list patterns don't force outer to split
if (obj case [[1, 2], [[3]]]) {;}
<<<
if (obj case [[1, 2], [[3]]]) {
;
}
>>> Split all elements and keep line comment on newline.
if (obj case [
// yeah
a,b,c,
d,e,f,
]) {;}
<<<
if (obj case [
// yeah
a,
b,
c,
d,
e,
f,
]) {
;
}
>>> Split in type argument, but not in the body.
if (obj case <Map<VeryLongTypeArgument, VeryLongTypeArgument>>[e]) {;}
<<<
if (obj case <
Map<
VeryLongTypeArgument,
VeryLongTypeArgument
>
>[e]) {
;
}
>>> Split in type argument and body.
if (obj case <Map<VeryLongTypeArgument, VeryLongTypeArgument>>[element,VeryLongElementElementElement]) {;}
<<<
if (obj case <
Map<
VeryLongTypeArgument,
VeryLongTypeArgument
>
>[
element,
VeryLongElementElementElement,
]) {
;
}
>>> Split inside element forces list to split.
if (obj case [first,secondLongPattern ||thirdVeryLongPattern]) {;}
<<<
if (obj case [
first,
secondLongPattern ||
thirdVeryLongPattern,
]) {
;
}
>>> Split in rest element does not split after "...".
if (obj case [...firstPattern || secondVeryLongPattern]) {;}
<<<
if (obj case [
...firstPattern ||
secondVeryLongPattern,
]) {
;
}
>>> A nested non-empty list pattern doesn't force the list pattern to split.
var [[v]] = value;
<<<
var [[v]] = value;
>>> A nested non-empty map pattern doesn't force the list pattern to split.
var [{k: v}] = value;
<<<
var [{k: v}] = value;
>>> A nested non-empty record pattern doesn't force the list pattern to split.
var [(v,)] = value;
<<<
var [(v,)] = value;
>>> Remove blank lines before first and last entries. Preserve one between.
if (obj case [
firstElement,
secondElement,
thirdElement
]) {;}
<<<
if (obj case [
firstElement,
secondElement,
thirdElement,
]) {
;
}
>>> Discard blank lines if doesn't need to split.
if (obj case [
1,
2,
3
]) {;}
<<<
if (obj case [1, 2, 3]) {
;
}