> 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/list/listappend.md).

# 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

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

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