How can I use wherecontains() for multiple conditions?
For example, let's say I have an array of my cdt type Person, called people:
[ name="Ben", age=20 ]; [ name: "Sam", age:50 ]
I could write wherecontains("Ben", people.name). This would return the first element in the array.
But what if the array looked like this:
[ name="Ben", age=20 ]; [ name: "Ben", age:50 ]
I still want to get the first index but wherecontains("Ben", people.name) would return both indices. How can I add a condition to check name AND age?
Discussion posts and replies are publicly visible
I would add that a!forEach is so powerful that you can basically use it to replace whereContains() altogether, and especially so in more complex use cases like this.
with( local!peopleArray: { { Name: "Mary", Age: 22 }, { Name: "Ben", Age: 22 }, { Name: "Ben", Age: 55 }, { Name: "Mike", Age: 39 } }, a!forEach( local!peopleArray, if( and( fv!item.Name = "Ben", tointeger(fv!item.Age) = 22 ), fv!index, {} ) ) )