# ListAppend

Appends an element to a list

## Method Signature

```
ListAppend(list=[string], value=[string], delimiter=[string], includeEmptyFields=[boolean], multiCharacterDelimiter=[boolean])
```

### Arguments

| Argument                  | Type      | Required | Description                                                    | Default |
| ------------------------- | --------- | -------- | -------------------------------------------------------------- | ------- |
| `list`                    | `string`  | `true`   | string list to filter entries from                             |         |
| `value`                   | `string`  | `true`   | The value to append                                            |         |
| `delimiter`               | `string`  | `false`  | string the list delimiter                                      | `,`     |
| `includeEmptyFields`      | `boolean` | `false`  | boolean whether to include empty fields in the returned result | `false` |
| `multiCharacterDelimiter` | `boolean` | `false`  | boolean whether the delimiter is multi-character               | `false` |

## Examples

### Simple listAppend Example

Add 'foo' to the end of this list

[Run Example](https://try.boxlang.io/?code=eJzLz0nxySwuUbBVUEpKLNIBYiMla6681HKoaA6QciwoSM1L0VDIh6jVUVBKy89XUtC05iovyixJ9S8tKSgtgUsrqCko6eraKQFpmDFAlQDxyCCh)

```java
oldList = "bar,bar2";
newList = listAppend( oldList, "foo" );
writeOutput( oldList & "-->" & newList );

```

Result: bar,bar2,foo

### Simple listAppend Example with Delimiter

Add 'foo' to the end of this list using a custom delimiter

[Run Example](https://try.boxlang.io/?code=eJzLz0nxySwuUbBVUEpKLNIBYiMla6681HKoaA6QciwoSM1L0VDIh6jVUVBKy89XAlI1Sgqa1lzlRZklqf6lJQWlJXA1CmoKSrq6dkpAGmYWUCUAhFMhrQ%3D%3D)

```java
oldList = "bar,bar2";
newList = listAppend( oldList, "foo", "|" );
writeOutput( oldList & "-->" & newList );

```

Result: bar,bar2|foo

### Simple listAppend Example with Empty Fields On

CF2018+ Add 'foo,,' to the end of this list using includeEmptyFields as true

[Run Example](https://try.boxlang.io/?code=eJzLz0nxySwuUbBVUEpKLNIBYiMla6681HKoaA6QciwoSM1L0VDIh6jVUVBKy8%2FX0VECMkBESVFpqoKmNVd5UWZJqn9pSUFpCVytgpqCkq6unRKQhpkJVAkAiv8jwQ%3D%3D)

```java
oldList = "bar,bar2";
newList = listAppend( oldList, "foo,,", ",", true );
writeOutput( oldList & "-->" & newList );

```

Result: bar,bar2,foo,,

### Simple listAppend Example with Empty Fields Off

CF2018+ Add 'foo' to the end of this list using includeEmptyFields as false

[Run Example](https://try.boxlang.io/?code=eJzLz0nxySwuUbBVUEpKLNIBYiMla6681HKoaA6QciwoSM1L0VDIh6jVUVBKy8%2FX0VECMkBEWmJOcaqCpjVXeVFmSap%2FaUlBaQlcsYKagpKurp0SkIYZClQJAK6NJAw%3D)

```java
oldList = "bar,bar2";
newList = listAppend( oldList, "foo,,", ",", false );
writeOutput( oldList & "-->" & newList );

```

Result: bar,bar2,foo

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJxVjr0KAjEQhPs8xZBGheD1HhaCjc29QzCrFzA%2FJBvivb254IFWC%2FPN7IxbXjYzzpDBk%2BIaFM%2BJSI7CLZ7qF67nEiN5s4frCQX5CCVJHEYxDJgCE3jW%2FGPFPZFmytBonzo44sYwgbLfMUo0uqcI9G7Q%2Bmc3nURNlulaXNza1pY%2FcZvW9A%2BFhkMn)

```java
mylist = "one,two,three";
mynewlist = listAppend( mylist, "four" );
// Note that listAppend creates a new list. It doesn't update the existing list:
writeDump( mylist );
writeDump( mynewlist );

```

[Run Example](https://try.boxlang.io/?code=eJzLrczJLC5RsFVQSsvPV7Lmyq3MSy2HCoEox4KC1LwUDYVcsDodBaWkxCIlIFWjpKBpzVVelFmS6lKaWwBSANMIFAcA50scNg%3D%3D)

```java
mylist = "foo";
mynewlist = listAppend( mylist, "bar", "|" );
writeDump( mynewlist );

```

## Related

* [GetToken](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/gettoken)
* [ListAvg](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listavg)
* [ListChangeDelims](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listchangedelims)
* [ListCompact](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listcompact)
* [ListContains](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listcontains)
* [ListContainsNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listcontainsnocase)
* [ListDeleteAt](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listdeleteat)
* [ListEach](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listeach)
* [ListEvery](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listevery)
* [ListFilter](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listfilter)
* [ListFind](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listfind)
* [ListFindNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listfindnocase)
* [ListFirst](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listfirst)
* [ListGetAt](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listgetat)
* [ListGetEndings](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listgetendings)
* [ListIndexExists](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listindexexists)
* [ListInsertAt](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listinsertat)
* [ListItemTrim](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listitemtrim)
* [ListLast](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listlast)
* [ListLen](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listlen)
* [ListMap](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listmap)
* [ListNone](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listnone)
* [ListPrepend](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listprepend)
* [ListQualify](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listqualify)
* [ListReduceRight](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listreduceright)
* [ListRemoveDuplicates](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listremoveduplicates)
* [ListRest](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listrest)
* [ListSetAt](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listsetat)
* [ListSome](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listsome)
* [ListSort](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listsort)
* [ListToArray](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listtoarray)
* [ListTrim](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listtrim)
* [ListValueCount](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listvaluecount)
* [ListValueCountNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listvaluecountnocase)


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/list/listappend.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
