From 4cee5f991631f8f61ac70dddf6b33c9165e0c489 Mon Sep 17 00:00:00 2001 From: hestonhoffman Date: Wed, 19 Jan 2022 15:09:10 -0800 Subject: [PATCH] (docs) Add example for next() --- lib/puppet/functions/next.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/puppet/functions/next.rb b/lib/puppet/functions/next.rb index 0f110d3d624..767aa54e7ff 100644 --- a/lib/puppet/functions/next.rb +++ b/lib/puppet/functions/next.rb @@ -1,8 +1,25 @@ # Makes iteration continue with the next value, optionally with a given value for this iteration. # If a value is not given it defaults to `undef` +# +# @example Using the `next()` function # -# @since 4.7.0 +# ```puppet +# $data = ['a','b','c'] +# $data.each |Integer $index, String $value| { +# if $index == 1 { +# next() +# } +# notice ("${index} = ${value}") +# } +# ``` +# +# Would notice: +# ``` +# Notice: Scope(Class[main]): 0 = a +# Notice: Scope(Class[main]): 2 = c +# ``` # +# @since 4.7.0 Puppet::Functions.create_function(:next) do dispatch :next_impl do optional_param 'Any', :value