24 Spread in collections
... inserts the elements of an iterable at one position in a collection literal.
norm
main() {
List<String> middle = ["run", "check"]
List<String> tail = ["share"]
List<String> steps = ["read", ...middle, "change", ...tail]
printLine(steps.size())
printLine(steps[0])
printLine(steps[2])
printLine(steps[3])
printLine(steps[4])
}Expected output:
text
5
read
check
change
shareThe middle list contributes run and check in order, and tail contributes share at the end. Neither source list becomes one nested element.
Try it: Spread an empty list and observe the new size.
Precise rules: Reference.