I came to know that we can create hash of hashes as below:
Hash.new{|hash, key| hash[key] = Hash.new}
But I dont understand whether the key and value getting converted as hash. Can someone explain me in brief about this.
I came to know that we can create hash of hashes as below:
Hash.new{|hash, key| hash[key] = Hash.new}
But I dont understand whether the key and value getting converted as hash. Can someone explain me in brief about this.
If you define
hash
this way, ruby set the default value on every key in hash to new hash and save it.sample
insted of define only default value