Skip to content

Puppet 4 Repetition - filter

This article in the series about Repetition and Loops in Puppet 4 deals with the filter function. The name already suggests the intended use-case: it takes a collection and picks elements based on a condition. The code block only has to take care of the decision logic for a single element. The item is only included in the result if the code block returns a true value. Iteration and assembly of the result happens automatically.

Continue reading "Puppet 4 Repetition - filter"

Puppet 4 Repetition - map

My series about Repetition and Loops in Puppet 4 continues with this article about the map function. The main difference between map and each is the handling of the return value. The map function uses the return value of the code block to build a new collection. This allows us to transform one collection into another collection by changing one element at a time.

Continue reading "Puppet 4 Repetition - map"