> For the complete documentation index, see [llms.txt](https://katxupa.gitbook.io/katxupa/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://katxupa.gitbook.io/katxupa/get-a-taste-of-katxupa/usage/scope-functions/functions/letit.md).

# letIt

***letIt(it => {** //do something here it **})***

* **The context object** is available as an argument (*it*).
* **The return value** is the lambda result.

*letIt* can be used to invoke one or more functions on results of call chains.

```typescript
const data: Array<number> | null = await idsFromFile();

const str = data?.letIt(it => convertToString(it)) ?? "empty";
```

You can also use withIt to introduce a helper object whose properties or functions are used for calculating a value.

```typescript
const numbers = mutableListOf<string>("one", "two", "three");

const firstAndLast = withIt(numbers, function () {
    return `The first element is ${this.first()}, the last element is ${this.last()}`
});
console.debug(firstAndLast);
```
