4 module Puppet::Parser::Functions
5 newfunction(:join, :type => :rvalue, :doc => <<-DOC
6 This function joins an array into a string using a separator.
10 join(['a','b','c'], ",")
12 Would result in: "a,b,c"
14 Note: from Puppet 5.4.0, the compatible function with the same name in Puppet core
15 will be used instead of this function.
19 # Technically we support two arguments but only first is mandatory ...
20 raise(Puppet::ParseError, "join(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
24 unless array.is_a?(Array)
25 raise(Puppet::ParseError, 'join(): Requires array to work with')
28 suffix = arguments[1] if arguments[1]
31 unless suffix.is_a?(String)
32 raise(Puppet::ParseError, 'join(): Requires string to work with')
36 result = suffix ? array.join(suffix) : array.join
42 # vim: set ts=2 sw=2 et :