Dela via


Initializing Modeling Collection Types in Cord

Spec Explorer provides three modeling collection types that are appropriate for use as action parameters: Map, Set, and Sequence.

Initialization in Cord of other variable types is done just as in C#.

Example

The following example demonstrates a compact syntax for initializing these collection types in Cord.

config ParameterCombination: Main
{
    action abstract static void
        Implementation.SetValues(Map<string, int> valuesMap)
        where valuesMap in {
            Map<string, int>{ "green"->1, "blue"->3, "cyan"->5 },
            Map<string, int>{ "green"->5, "red"->4, "yellow"->7 },
            Map<string, int>{} };

    action abstract static Map<string, int>
        Implementation.GetValues(Set<string> keySet)
        where keySet in {
            Set<string>{ "green", "blue" },
            Set<string>{ "red", "orange" },
            Set<string>{ "cyan" },
            Set<string>{} };

    action abstract static Sequence<int>
        Implementation.RemoveDuplicateElements(Sequence<int> queue)
        where queue in {
            Sequence<int>{ 1, 3, 2 },
            Sequence<int>{ 2, 2, 2 },
            Sequence<int>{ 1 },
            Sequence<int>{} };
}

See Also

Reference

CordScript

Concepts

Cord Syntax Definition