Adding Variables to a Hash in Ruby -


i needed add variable hash. trying this:

actorschickens = hash.new nicolascage = gets.chomp # string chickencount = gets.chomp # string representing number (i.e "5") actorschickens[#{nicolascage} => #{chickencount}] 

what doing wrong? can add variable hash?

i think you're trying this:

your_hash = {} hash_key = gets.chomp hash_value = gets.chomp your_hash[hash_key] = hash_value 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -