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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -