From: Love U Ruby Date: 2013-04-02T02:28:02+09:00 Subject: Recursion with Hash h = {a: {b: {c: 23}}} def hash_brek(h) h.each_with_object({}) do |i,temp| temp[i.first] = i.last p temp if h.eql? ({c: 23}) then p "hi" temp[i.first] = i.last return temp end hash_brek(i.last) end end p hash_brek(h) output: D:\Rubyscript\My ruby learning days\Scripts>practice.rb "2.0.0" {:a=>{:b=>{:c=>23}}} {:b=>{:c=>23}} {:c=>23} {:a=>{:b=>{:c=>23}}} But I wanted the output as: {:a=>{:b=>{:c=>23}}} {:a=>{:b=>{:c=>23}},:b=>{:c=>23}} {:a=>{:b=>{:c=>23}},:b=>{:c=>23},:c=>23} {:a=>{:b=>{:c=>23}},:b=>{:c=>23},:c=>23} Can you point where did I the wrong, thus not getting the output as above? -- Posted via http://www.ruby-forum.com/.