Ruby Hash | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Ruby Hash

I have code info = {name:""} puts = "Enter name" name = gets How I can change value of :name to variable 'name'?

18th Sep 2018, 9:00 PM
Влад Фотьянов
Влад Фотьянов - avatar
1 Answer
+ 5
You can use this sentence: info [:name] = name Example: info = {name:""} puts = "Enter name" name = gets #asign value name to the hash info [:name] = name puts info[:name] info [:name] = "Myself" puts info[:name]
18th Sep 2018, 11:15 PM
Nimrod A. Holguín L.
Nimrod A. Holguín L. - avatar