blob: 92ad8458f16a500e4475801f933a490ecfe5b885 [file] [log] [blame]
40 columns |
### Pattern variable declaration statements.
>>> Basic syntax.
{
var ( a && b ) = o;
var ( a as int , String ? b ) = o;
var ( : inferred ) = o;
final [ a ! , Foo ( : b ) , ... ] = o;
final { 'k' : _ , ... } = o;
var Foo ( prop : value , : inferred ) = o;
}
<<<
{
var (a && b) = o;
var (a as int, String? b) = o;
var (:inferred) = o;
final [a!, Foo(:b), ...] = o;
final {'k': _, ...} = o;
var Foo(prop: value, :inferred) = o;
}
>>> Prefer to split at "=" instead of pattern.
var (longIdentifier && anotherOne) = value;
<<<
var (longIdentifier && anotherOne) =
value;
>>> Split in infix pattern.
var (longIdentifier && anotherAlsoLongOne) = value;
<<<
var (longIdentifier &&
anotherAlsoLongOne) =
value;
>>> Split in list pattern.
var [first, second, third, fourth, fifth] = value;
<<<
var [
first,
second,
third,
fourth,
fifth,
] = value;
>>> Split in initializer but not block-splittable pattern.
var [first] = expression + anotherOperand + aThirdOperand;
<<<
var [first] =
expression +
anotherOperand +
aThirdOperand;
>>> Split in map pattern.
var {first: second, third: fourth, fifth: sixth} = value;
<<<
var {
first: second,
third: fourth,
fifth: sixth,
} = value;
>>> Split in record pattern.
var (first, second, third, fourth, fifth) = value;
<<<
var (
first,
second,
third,
fourth,
fifth,
) = value;
>>> Split in object pattern.
var Foo(:first, :second, :third, :fourth, :fifth) = value;
<<<
var Foo(
:first,
:second,
:third,
:fourth,
:fifth,
) = value;
>>> Split in value.
var (first, second, third) = longValueExpression + anotherOperand + aThirdOperand;
<<<
var (first, second, third) =
longValueExpression +
anotherOperand +
aThirdOperand;
>>> Expression split in both.
var (longIdentifier && anotherAlsoLongOne) = longValueExpression + anotherOperand + aThirdOperand;
<<<
var (longIdentifier &&
anotherAlsoLongOne) =
longValueExpression +
anotherOperand +
aThirdOperand;
>>> Block split in both.
var (first, second, third, fourth, fifth) = (first, second, third, fourth, fifth);
<<<
var (
first,
second,
third,
fourth,
fifth,
) = (
first,
second,
third,
fourth,
fifth,
);
>>> Expression split in pattern, block split in value.
var (longIdentifier && anotherAlsoLongOne) = (first, second, third, fourth, fifth);
<<<
var (longIdentifier &&
anotherAlsoLongOne) = (
first,
second,
third,
fourth,
fifth,
);
>>> Block split in pattern, expression split in value.
var (first, second, third, fourth, fifth) = longValueExpression + anotherOperand + aThirdOperand;
<<<
var (
first,
second,
third,
fourth,
fifth,
) = longValueExpression +
anotherOperand +
aThirdOperand;