intuit / intuit/common-xtext-expression-language

Support `it` keyword in map function

Open
#21 1 comment 0 reactions 1 assignee Claimed by @shreyagajane View on GitHub
enhancement hard
Dominant language
Java
Stars
11
Forks
6
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
I have an array of objects like below

```
[
{...},
{...}
...
]
```
I want to map it to a new array like below
```
[
{ "someKey" : {...} },
{ "someKey" : {...} },
...
]
```
It is not possible to perform such a transformation using the map method.

**Describe the solution you'd like**

Below is an example of pickFIrst function usage.
```
pickFirst(a,b,c -> it != null)
```
It already has a concept of `it` reference, which is a self-reference to the current object while iterating over a,b and c.

We can apply this concept to the map function so that the above transformation can be achieved by
```
map(myArray -> {
someKey = it
})
```

**Describe alternatives you've considered**
None of the supported functions support this usecase

**Additional context**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.