# StructUpdate

Updates or sets a key/value pair in to a struct

## Method Signature

```
StructUpdate(struct=[modifiableStruct], key=[any], value=[any])
```

### Arguments

| Argument | Type               | Required | Description                               | Default |
| -------- | ------------------ | -------- | ----------------------------------------- | ------- |
| `struct` | `modifiableStruct` | `true`   | The target struct                         |         |
| `key`    | `any`              | `true`   | The struct key                            |         |
| `value`  | `any`              | `true`   | The value to assign for the specified key |         |

## Examples

### Updates a structure value at specific key

Change value of structure item

[Run Example](https://try.boxlang.io/?code=eJzLrQwuKSpNLlGwVahW4OJ0VLBSMNTh4nQC0kZA2hlIGwNpFyBtwlVrzVUMVh1akJJYkqqhkAvVraOglKyko2BoqqBpzVVelFmS6lKaW6Ch4BXs7xecWpSZmJNZhaRcQROkDgDFciI%2F)

```java
myStruct = { 
	A : 1,
	B : 2,
	C : 3,
	D : 4
};
structUpdate( myStruct, "c", 15 );
writeDump( JSONSerialize( myStruct ) );

```

Result: {"A":1,"B":2,"C":15,"D":4}

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJxljk0LgjAcxs%2FuUzz8TwaC98KDGESnAovOSweOdJO15SH67unUyDo%2Bbz8ermTD6zsSPMGC7HDBGtRoTRELjvvdoLRUt0Fm6cmHQnfEXhsWx8gr3aFwxghlwUcU27qmDVHzq6gTypYhRXhwk0wKK085tyW3AgW3kOqDya1xhR2zcHYjUF%2FrKdT2YJoA%2FsbM7KSt4Pys%2FGUurqXfg6E4jf4%2FvgHMuF3T)

```java
animals = { 
	COW : "moo",
	PIG : "oink",
	CAT : "meow"
};
// Show current animals
Dump( label="Current animals", var=animals );
// Update cat in animals
StructUpdate( animals, "cat", "purr" );
// Show animals with updated cat in animals
Dump( label="Animals with cat updated", var=animals );

```

## Related

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