Sha256: 9c0cf9e6a8728639d8ad8bc167693c89f64b412e802446a267ad925adc9a29db

Contents?: true

Size: 715 Bytes

Versions: 32

Compression:

Stored size: 715 Bytes

Contents

# frozen_string_literal: true

# Returns the keys of a hash as an Array
#
# @example Using `keys`
#
# ```puppet
# $hsh = {"apples" => 3, "oranges" => 4 }
# $hsh.keys()
# keys($hsh)
# # both results in the array ["apples", "oranges"]
# ```
#
# * Note that a hash in the puppet language accepts any data value (including `undef`) unless
#   it is constrained with a `Hash` data type that narrows the allowed data types.
# * For an empty hash, an empty array is returned.
# * The order of the keys is the same as the order in the hash (typically the order in which they were added).
#
Puppet::Functions.create_function(:keys) do
  dispatch :keys do
    param 'Hash', :hsh
  end

  def keys(hsh)
    hsh.keys
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
puppet-8.10.0 lib/puppet/functions/keys.rb
puppet-8.10.0-x86-mingw32 lib/puppet/functions/keys.rb
puppet-8.10.0-x64-mingw32 lib/puppet/functions/keys.rb
puppet-8.10.0-universal-darwin lib/puppet/functions/keys.rb
puppet-8.9.0 lib/puppet/functions/keys.rb
puppet-8.9.0-x86-mingw32 lib/puppet/functions/keys.rb
puppet-8.9.0-x64-mingw32 lib/puppet/functions/keys.rb
puppet-8.9.0-universal-darwin lib/puppet/functions/keys.rb
puppet-8.8.1 lib/puppet/functions/keys.rb
puppet-8.8.1-x86-mingw32 lib/puppet/functions/keys.rb
puppet-8.8.1-x64-mingw32 lib/puppet/functions/keys.rb
puppet-8.8.1-universal-darwin lib/puppet/functions/keys.rb
puppet-8.7.0 lib/puppet/functions/keys.rb
puppet-8.7.0-x86-mingw32 lib/puppet/functions/keys.rb
puppet-8.7.0-x64-mingw32 lib/puppet/functions/keys.rb
puppet-8.7.0-universal-darwin lib/puppet/functions/keys.rb
puppet-8.6.0 lib/puppet/functions/keys.rb
puppet-8.6.0-x86-mingw32 lib/puppet/functions/keys.rb
puppet-8.6.0-x64-mingw32 lib/puppet/functions/keys.rb
puppet-8.6.0-universal-darwin lib/puppet/functions/keys.rb