Combining arrays #171
Closed
springcomp
started this conversation in
Ideas
Replies: 1 comment
-
The
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The current specification does not have an easy way to create an array that contains all entries from a set of arrays.
Consider the following scenario:
How do we return the result of concatenating
foo
andboo
?One answer is to use the
join
andsplit
functions like so:split( join(',', [ join(',', foo), join(',', foo) ]), ',')
This returns:
The idea would be to overload the
merge
function which already exists for objects and have it operate on arrays as well.Specification
merge
Accepts zero or more objects and returns a single object with all key/value pairs merged. The function is used to combine multiple objects into one. You can think of as the function using the first object argument as a base object, to which all key/value pairs from subsequent object arguments are merged, one after the other.
Accepts zero or more arrays and returns a single array with all entries combined. The function is used to combine multiple arrays into one.
Examples
merge()
ex
merge(`{ }`)
{}
merge([ ])
[]
{ "foo": ["bar", "baz"], "boo": ["one", "two"] }
merge(foo, boo)
[ "bar", "baz", "one", "two" ]
Beta Was this translation helpful? Give feedback.
All reactions