StructDelete

Deletes a key from a struct

Method Signature

StructDelete(struct=[modifiableStruct], key=[any])

Arguments

Argument
Type
Required
Description
Default

struct

modifiableStruct

true

The struct target

key

any

true

The key to delete

Examples

Remove a key from a struct

Creates a struct then removes a key

Run Example

someStruct = { 
	A : 1,
	B : 2
};
structDelete( someStruct, "a" );
writeDump( someStruct );

Result: Struct with one key-value pair: B 2

Remove a key from a struct using the member function

Invoking the delete function on a struct is the same as running structDelete.

Run Example

someStruct = { 
	A : 1,
	B : 2
};
someStruct.delete( "a" );
writeDump( someStruct );

Result: Struct with one key-value pair: B 2

Additional Examples

Run Example

animals = { 
	COW : "moo",
	PIG : "oink",
	CAT : "meow"
};
// Show current animals
Dump( label="Current animals", var=animals );
// Delete the key 'cat' from struct
StructDelete( animals, "cat" );
// Show animals, cat has been deleted
Dump( label="Animals with cat deleted", var=animals );

Last updated

Was this helpful?