4 module Puppet::Parser::Functions
5 newfunction(:concat, :type => :rvalue, :doc => <<-DOC
6 Appends the contents of multiple arrays into array 1.
10 concat(['1','2','3'],['4','5','6'],['7','8','9'])
14 ['1','2','3','4','5','6','7','8','9']
16 Note: Since Puppet 4.0 concatenation of arrays and hashes can be done with the + operator.
18 ['1','2','3'] + ['4','5','6'] + ['7','8','9']
22 # Check that more than 2 arguments have been given ...
23 raise(Puppet::ParseError, "concat(): Wrong number of arguments given (#{arguments.size} for < 2)") if arguments.size < 2
27 # Check that the first parameter is an array
29 raise(Puppet::ParseError, 'concat(): Requires array to work with')
36 result += (x.is_a?(Array) ? x : [x])
43 # vim: set ts=2 sw=2 et :