PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
| Dir : /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/functions/ |
| Server: Linux server1.ngambekcore.com 4.18.0-553.51.1.el8_10.x86_64 #1 SMP Wed Apr 30 04:00:07 EDT 2025 x86_64 IP: 159.198.77.92 |
| Dir : //opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/functions/length.rb |
# Returns the length of an Array, Hash, String, or Binary value.
#
# The returned value is a positive integer indicating the number
# of elements in the container; counting (possibly multibyte) characters for a `String`,
# bytes in a `Binary`, number of elements in an `Array`, and number of
# key-value associations in a Hash.
#
# @example Using `length`
#
# ```puppet
# "roses".length() # 5
# length("violets") # 7
# [10, 20].length # 2
# {a => 1, b => 3}.length # 2
# ```
#
# @since 5.5.0 - also supporting Binary
#
Puppet::Functions.create_function(:length) do
dispatch :collection_length do
param 'Collection', :arg
end
dispatch :string_length do
param 'String', :arg
end
dispatch :binary_length do
param 'Binary', :arg
end
def collection_length(col)
col.size
end
def string_length(s)
s.length
end
def binary_length(bin)
bin.length
end
end