Skip to content
instance method

Hash#transform_values!

() -> ::Enumerator[V, self]
() { (V) -> V } -> self
transform_values! {|old_value| ... } → self
transform_values! → new_enumerator

With a block given, changes the values of self as determined by the block; returns self.

For each entry key/old_value in self, calls the block with old_value, captures its return value as new_value, and sets self[key] = new_value:

Example
h = {foo: 0, bar: 1, baz: 2}
h.transform_values! {|value| value * 100} # => {foo: 0, bar: 100, baz: 200}

With no block given, returns a new Enumerator.

Related: see Methods for Transforming Keys and Values.