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
Post a Comment