ToUnmodifiable
Convert an array, struct, query or set to its Unmodifiable counterpart.
Method Signature
ToUnmodifiable(value=[any])Arguments
Argument
Type
Required
Description
Default
value
any
true
The array, struct, query or set to convert.
Examples
Convert to an unmodifiable (immutable) copy
data = { name: "test" };
frozen = toUnmodifiable( data );
writeOutput( isObject( frozen ) );
Result: true
Mutating an unmodifiable struct throws an error
data = [ 1, 2, 3 ];
frozen = data.toUnmodifiable();
try {
frozen.append( 4 );
writeOutput( "error" );
} catch ( any e ) {
writeOutput( "caught" );
}
Result: caught
Related
Last updated
Was this helpful?
