Puppet Function: union
- Defined in:
-
vendor_modules/stdlib/lib/puppet/parser/functions/union.rb
- Function type:
- Ruby 3.x API
Summary
This function returns a union of two or more arrays.
Overview
union() ⇒ Any
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'vendor_modules/stdlib/lib/puppet/parser/functions/union.rb', line 7
newfunction(:union, type: :rvalue, doc: <<-DOC
@summary
This function returns a union of two or more arrays.
@return
a unionized array of two or more arrays
@example **Usage**
union(["a","b","c"],["b","c","d"])
Would return: ["a","b","c","d"]
DOC
) do |arguments|
raise(Puppet::ParseError, "union(): Wrong number of arguments given (#{arguments.size} for < 2)") if arguments.size < 2
arguments.each do |argument|
raise(Puppet::ParseError, 'union(): Every parameter must be an array') unless argument.is_a?(Array)
end
arguments.reduce(:|)
end
|