Iterates through this Hash, calling the passed function for each value, passing to the function the current value as the first parameter. The method can take an optional second parameter as an Array object (arguments). The elements of this array will be passed to the function as additional parameters.

hash.each_value(func as Function, arguments? as Array) as Hash


  • func. A reference to a function. This function must have been defined with at least one parameter as the current value will be passed to it. This function may have additional parameters defined and these will be passed to it as the contents of the optional arguments array
  • arguments. Optional Array object. Each element of this array will be passed to func as additional parameters after the current value


  • This unaltered Hash


function put(v) {
    print("The value is " + v)
function putSuffix(v, suffix) {
    print("The value is " + v + suffix)
var h = {"a" => 100, "b" => 200}
# Prints:
# The value is 100
# The value is 200

h.each_value(putSuffix, [" silly!"])
# Prints:
# The value is 100 silly!
# The value is 200 silly!