4 module Puppet::Parser::Functions
5 newfunction(:flatten, :type => :rvalue, :doc => <<-DOC
6 This function flattens any deeply nested arrays and returns a single flat array
11 flatten(['a', ['b', ['c']]])
13 Would return: ['a','b','c']
15 Note: from Puppet 5.5.0, the compatible function with the same name in Puppet core
16 will be used instead of this function.
20 raise(Puppet::ParseError, "flatten(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
24 unless array.is_a?(Array)
25 raise(Puppet::ParseError, 'flatten(): Requires array to work with')
28 result = array.flatten
34 # vim: set ts=2 sw=2 et :