> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structdelete.md).

# 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](https://try.boxlang.io/?code=eJwrzs9NDS4pKk0uUbBVqFbg4nRUsFIw1OHidALSRly11lzFYFmX1JzUklQNhWK4eh0FpUQlBU1rrvKizJJUl9LcAmRZkAQA87UcEg%3D%3D)

```java
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](https://try.boxlang.io/?code=eJwrzs9NDS4pKk0uUbBVqFbg4nRUsFIw1OHidALSRly11lzFcBV6Kak5qSWpGgpKiUoKmtZc5UWZJakupbkFGgoIRSAJACeFGW8%3D)

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

```

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

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJxljsEKgkAURdfNV1xmo4HgvnAhCtGqwKD1qC8URyfGMYno39NxCqTV43LuuxzR1a2QPSK8wDbJ6YodeKsUD9jmfDzMSdVdM8ckvlhIauTsvWdhiKxSI4pBa%2BoMxDLF0qG9%2B5AiJxnxZA15gIfQkUvY2pWUJBmCqQgNPeEVwni4adWiN3ooDMvsWWr%2BdyoAn4rcbViTH5kAKtEjJ%2BpQ2r9y7RU7g7E2la271r%2FgB5NlXFk%3D)

```java
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 );

```

## Related

* [StructAppend](/boxlang-language/reference/built-in-functions/struct/structappend.md)
* [StructClear](/boxlang-language/reference/built-in-functions/struct/structclear.md)
* [StructCopy](/boxlang-language/reference/built-in-functions/struct/structcopy.md)
* [StructEach](/boxlang-language/reference/built-in-functions/struct/structeach.md)
* [StructEquals](/boxlang-language/reference/built-in-functions/struct/structequals.md)
* [StructEvery](/boxlang-language/reference/built-in-functions/struct/structevery.md)
* [StructFilter](/boxlang-language/reference/built-in-functions/struct/structfilter.md)
* [StructFind](/boxlang-language/reference/built-in-functions/struct/structfind.md)
* [StructFindKey](/boxlang-language/reference/built-in-functions/struct/structfindkey.md)
* [StructFindValue](/boxlang-language/reference/built-in-functions/struct/structfindvalue.md)
* [StructGet](/boxlang-language/reference/built-in-functions/struct/structget.md)
* [StructGetMetadata](/boxlang-language/reference/built-in-functions/struct/structgetmetadata.md)
* [StructInsert](/boxlang-language/reference/built-in-functions/struct/structinsert.md)
* [StructIsCaseSensitive](/boxlang-language/reference/built-in-functions/struct/structiscasesensitive.md)
* [StructIsOrdered](/boxlang-language/reference/built-in-functions/struct/structisordered.md)
* [StructKeyArray](/boxlang-language/reference/built-in-functions/struct/structkeyarray.md)
* [StructKeyExists](/boxlang-language/reference/built-in-functions/struct/structkeyexists.md)
* [StructKeyList](/boxlang-language/reference/built-in-functions/struct/structkeylist.md)
* [StructKeyTranslate](/boxlang-language/reference/built-in-functions/struct/structkeytranslate.md)
* [StructMap](/boxlang-language/reference/built-in-functions/struct/structmap.md)
* [StructNew](/boxlang-language/reference/built-in-functions/struct/structnew.md)
* [StructNone](/boxlang-language/reference/built-in-functions/struct/structnone.md)
* [StructReduce](/boxlang-language/reference/built-in-functions/struct/structreduce.md)
* [StructSome](/boxlang-language/reference/built-in-functions/struct/structsome.md)
* [StructSort](/boxlang-language/reference/built-in-functions/struct/structsort.md)
* [StructToQueryString](/boxlang-language/reference/built-in-functions/struct/structtoquerystring.md)
* [StructToSorted](/boxlang-language/reference/built-in-functions/struct/structtosorted.md)
* [StructUpdate](/boxlang-language/reference/built-in-functions/struct/structupdate.md)
* [StructValueArray](/boxlang-language/reference/built-in-functions/struct/structvaluearray.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/struct/structdelete.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
