date - Puts Hash in Ruby -


i have hash, , want print it:

{:date=>#<date: 2013-03-29 ((2456381j,0s,0n),+0s,2299161j)>, :name=>"karfreitag", :regions=>[:de]} {:date=>#<date: 2013-04-01 ((2456384j,0s,0n),+0s,2299161j)>, :name=>"ostermontag", :regions=>[:de]} {:date=>#<date: 2013-05-01 ((2456414j,0s,0n),+0s,2299161j)>, :name=>"tag der arbeit", :regions=>[:de]} 

i tried with:

def print_holiday(a)           a.each |date|     puts date["name"] + " " + date["date"]   end                    end 

but empty lines. got ideas?

i'm using holidays gem.

a string not symbol. keys in hash symbols, you're trying access values through strings.

try this:

puts date[:name] + " " + date[:date] 

the difference between ruby symbols , strings


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -