T
transfire
Is this form of Hash initialization really very useful?
Hash.new(obj) => aHash
If _obj_ is specified, this single object will be used for all
_default values_.
Since the object is the _same_ object every time, I have never found a
use for it. I would much rather:
Hash.new( hash ) => aHash
If _hash_ is specified, the key-value pairs of this hash will
populate the new hash.
Besides, you can still get the former behavior like this:
Hash.new { |h,k| h[k] = obj }
And if that's not enough then:
Hash.new_with_default(obj)
T.
Hash.new(obj) => aHash
If _obj_ is specified, this single object will be used for all
_default values_.
Since the object is the _same_ object every time, I have never found a
use for it. I would much rather:
Hash.new( hash ) => aHash
If _hash_ is specified, the key-value pairs of this hash will
populate the new hash.
Besides, you can still get the former behavior like this:
Hash.new { |h,k| h[k] = obj }
And if that's not enough then:
Hash.new_with_default(obj)
T.