ruby - Iterating over values for array of hashes -


i have array of hashes like:

award = [           {'karma_points' => %w(initiate apprentice knight ace guardian sage master grand_master)},          {'microblogs_posted' => %w(uno_plus)},          {'comments_posted' => %w(first_responder)},          {'ideas_posted' => %w(aryabhatta newton einstein)}        ] 

need iterate on values key if matches particular key in given hash (award).

any suggestion , solution appreciated.

is want :

award.each |hash|    # used hash#[] method. method return key if found, or nil.    # `nil` treated falsy in ruby, on nil **unless** block wouldn't executed,    # otherwise will.    unless hash['match_key'].nil?      # calling here `hash#each` method.      hash.each |key,value|        value.each |elem| # values array, calling array#each          # code        end      end    end end 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -