Sha256: 47705a0788806770a1742e38cf8398a484b4e0b077b1c3637acdd21130ce8fed

Contents?: true

Size: 789 Bytes

Versions: 20

Compression:

Stored size: 789 Bytes

Contents

# frozen_string_literal: true
# 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
#
# ```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
  end

  def next_impl(value = nil)
    file, line = Puppet::Pops::PuppetStack.top_of_stack
    exc = Puppet::Pops::Evaluator::Next.new(value, file, line)
    raise exc
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.3.0 lib/puppet/functions/next.rb
puppet-8.3.0-x86-mingw32 lib/puppet/functions/next.rb
puppet-8.3.0-x64-mingw32 lib/puppet/functions/next.rb
puppet-8.3.0-universal-darwin lib/puppet/functions/next.rb
puppet-8.3.1 lib/puppet/functions/next.rb
puppet-8.3.1-x86-mingw32 lib/puppet/functions/next.rb
puppet-8.3.1-x64-mingw32 lib/puppet/functions/next.rb
puppet-8.3.1-universal-darwin lib/puppet/functions/next.rb
puppet-8.2.0 lib/puppet/functions/next.rb
puppet-8.2.0-x86-mingw32 lib/puppet/functions/next.rb
puppet-8.2.0-x64-mingw32 lib/puppet/functions/next.rb
puppet-8.2.0-universal-darwin lib/puppet/functions/next.rb
puppet-8.1.0 lib/puppet/functions/next.rb
puppet-8.1.0-x86-mingw32 lib/puppet/functions/next.rb
puppet-8.1.0-x64-mingw32 lib/puppet/functions/next.rb
puppet-8.1.0-universal-darwin lib/puppet/functions/next.rb
puppet-8.0.1 lib/puppet/functions/next.rb
puppet-8.0.1-x86-mingw32 lib/puppet/functions/next.rb
puppet-8.0.1-x64-mingw32 lib/puppet/functions/next.rb
puppet-8.0.1-universal-darwin lib/puppet/functions/next.rb