Spec-Zone.ru › ColdFusion

structCopy

Copies a structure. Copies top-level keys, values, and arrays in the structure by value; copies nested structures by reference.

structCopy(structure) → returns struct

  • CF4+
  • Lucee
  • BL 1.0.0+
  • See Also: duplicate

    Argument Reference

    structure struct
    Required

    Structure to copy

    Examples
    Sample code invoking the structCopy function

    Copy a structure and change it. Original structure stays unchanged

    myStruct = {
        'a': 1,
        'b': 2,
        'c': 3
    };
    myNewStruct = structCopy(myStruct);
    myNewStruct.b = 5;
    myNewStruct['d'] = 4;
    structDelete(myNewStruct,'c');
    writeOutput(structKeyList(myStruct)&' → '&structKeyList(myNewStruct));

    Expected Result: b,a,c → b,a,d

    © 2012–present Foundeo, Inc. and the CFDocs contributors.
    Licensed under the MIT License.
    ColdFusion is a trademark of Adobe Systems Incorporated.
    https://cfdocs.org/structcopy

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API