From: Nick Black Date: 2007-02-02T19:56:25+09:00 Subject: Adding to Hashes Hello, I need to add key and value pairs to a hash dynamically. I want to do this: array = [] array << "hello" array << "world" But with k v pairs of a hash. The hash is being populated from a database and there is a potenitally unlimited (though realistically limited to less than 20) number of differnet keys, which my program will not know about until it talks to the database. Can I dynamically create a hash something like this: dbh.query("select k, v from foo where id = #{id}").each_hash do |kv| k = kv['k'] v = kv['v'] myhash << k,v end return myhash Thanks for the help!