Hello everybody, a question about expressions and arrays here. I have

Certified Associate Developer
Hello everybody, a question about expressions and arrays here.

I have a function that takes an array of users.

I have multiple arrays of users that I want to call my function on after applying a merge (ie: I want to call my function on the first element of each array, then the second of each array, etc etc). However the apply function treats the result of a merge as individual arguments instead of a single array object when calling my expression. Wrapping the _ placeholder in the apply function with curly brackets causes a syntax error as does casting the result of the merge to a user list.

Has anyone dealt with this before and if so how did you resolve it?

OriginalPostID-138030

OriginalPostID-138030

  Discussion posts and replies are publicly visible

Parents
  • jpheh, consider applying the append function after the merge. To illustrate: apply(fn!tostring, apply(fn!append, merge({"a", "b", "c"}, {1, 2, 3}))) returns: a1, b2, c3. Whereas: apply(fn!tostring, merge({"a", "b", "c"}, {1, 2, 3})) returns: a, b, c. This demonstrates that tostring was being passed an array when we apply the append, but was being passed multiple distinct elements when just using the merge. As you correctly state that "the apply function treats the result of a merge as individual arguments instead of a single array object when calling my expression.", we can use an applied append to combine the merged distinct elements into an array.
Reply
  • jpheh, consider applying the append function after the merge. To illustrate: apply(fn!tostring, apply(fn!append, merge({"a", "b", "c"}, {1, 2, 3}))) returns: a1, b2, c3. Whereas: apply(fn!tostring, merge({"a", "b", "c"}, {1, 2, 3})) returns: a, b, c. This demonstrates that tostring was being passed an array when we apply the append, but was being passed multiple distinct elements when just using the merge. As you correctly state that "the apply function treats the result of a merge as individual arguments instead of a single array object when calling my expression.", we can use an applied append to combine the merged distinct elements into an array.
Children
No Data