Skip to content

Commit 4cee5f9

Browse files
committed
(docs) Add example for next()
1 parent 29b3e90 commit 4cee5f9

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

lib/puppet/functions/next.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
# Makes iteration continue with the next value, optionally with a given value for this iteration.
22
# If a value is not given it defaults to `undef`
3+
#
4+
# @example Using the `next()` function
35
#
4-
# @since 4.7.0
6+
# ```puppet
7+
# $data = ['a','b','c']
8+
# $data.each |Integer $index, String $value| {
9+
# if $index == 1 {
10+
# next()
11+
# }
12+
# notice ("${index} = ${value}")
13+
# }
14+
# ```
15+
#
16+
# Would notice:
17+
# ```
18+
# Notice: Scope(Class[main]): 0 = a
19+
# Notice: Scope(Class[main]): 2 = c
20+
# ```
521
#
22+
# @since 4.7.0
623
Puppet::Functions.create_function(:next) do
724
dispatch :next_impl do
825
optional_param 'Any', :value

0 commit comments

Comments
 (0)