J
Josselin
I need to produce this kind of result
l = { "January" => "1"}, {"February => "2"}, { "March" => "3"}, .... }
so I wrote
h = (Array.new(13) {|i| Hash[Date::MONTHNAMES, i.to_s]}).slice(1,12)
which results in :
[{"January"=>"1"}, {"February"=>"2"}, {"March"=>"3"}, {"April"=>"4"},
{"May"=>"5"}, {"June"=>"6"}, {"July"=>"7"}, {"August"=>"8"},
{"September"=>"9"}, {"October"=>"10"}, {"November"=>"11"},
{"December"=>"12"}]
but I cannot write : l = { h } it's wrong... Hash cannot be
converted like that..
what should I write instead ?
thanks
joss
l = { "January" => "1"}, {"February => "2"}, { "March" => "3"}, .... }
so I wrote
h = (Array.new(13) {|i| Hash[Date::MONTHNAMES, i.to_s]}).slice(1,12)
which results in :
[{"January"=>"1"}, {"February"=>"2"}, {"March"=>"3"}, {"April"=>"4"},
{"May"=>"5"}, {"June"=>"6"}, {"July"=>"7"}, {"August"=>"8"},
{"September"=>"9"}, {"October"=>"10"}, {"November"=>"11"},
{"December"=>"12"}]
but I cannot write : l = { h } it's wrong... Hash cannot be
converted like that..
what should I write instead ?
thanks
joss