ruby create nested hash from array code example Example: ruby create nested hash from array h = array.reverse.inject(value) { |a, n| { n => a } }