From: Joachim Glauche Date: 2007-10-11T20:08:09+09:00 Subject: Re: Dynamically create hash I've no idea why you want this, but I think you want to have an array of hashes to iterate through. like this: hashes = [] for i in 0..9 hashes[i] = {"key" => "val"} end so hashes contains [{"key"=>"val"}, {"key"=>"val"}, {"key"=>"val"}, {"key"=>"val"}, {"key"=>"val"}, {"key"=>"val"}, {"key"=>"val"}, {"key"=>"val"}, {"key"=>"val"}, {"key"=>"val"}] Matthias Wiemann wrote: > Hi, > i would like to dynamically create hashes, so that I can create them by > looping over the names. > > Something like: > > for i in 1..10 > "hash#{i}" = Hash.new > "hash#{i}" = [:key => "val"] > end > > So the hashes created would go by the names hash1, hash2, hash3... > > Does anyone know how to do that? > > thanks > mat -- Posted via http://www.ruby-forum.com/.