Cold Help System: Programming: ColdC Reference Manual: Language Structure: Expressions: Operators: List Splice Operator


Splicing is used to either expand a list or in scatter assignments and method calls to group remaining arguments into a list. The splice operator is an at sign (@).

Splice can be used to expand a list in three situations: within a method call, within a function call or within another list When expanding, elements within the list to be spliced are placed starting at the appropriate position within the spliced list. For example:

[1, @['a, 'b, 'c], 2, 3]
[1, 'a, 'b, 'c, 2, 3]

Note: the function listgraft() behaves in the same manner. When using splice to expand a list as arguments to a function it looks similar:

others = [1, "this"];
$string.do_something(this, that, @others);

When the method do_something is called it would be called with four arguments, and the last two arguments would have a value of 1 and "this".

The splicing operator is always evaluated last, and is not listed in the operator precedence list (see section Precedence). Because of its restricted nature the splicing operator never causes ambiguity.


Operator Precedence | Index Operators | Arithmetic Operators | Assignments | Logical Operators | Conditional | List Splice Operator


the Cold Dark