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