Last active
March 20, 2017 11:15
-
-
Save asterion/eb61d47a104dcd93a28ca9f55b2090d8 to your computer and use it in GitHub Desktop.
persona
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
persona = { | |
nombre: "kyary", | |
edad: 24, | |
twitter: "twitter.pamyurin" | |
} | |
puts "desea añadir una clave y valor al hash? : " | |
resp = gets.chomp | |
if resp == "si" | |
puts "cual es el nombre de la nueva clave?? : " | |
resp_clave = gets.chomp.to_sym | |
puts "cual es el valor asociado a la clave?? : " | |
resp_valor = gets.chomp | |
persona[resp_clave] = resp_valor | |
elsif resp == "no" | |
puts "ok" | |
else | |
puts "no es una respuesta valida!" | |
end | |
persona.each { |clave, valor| puts "#{clave}: #{valor}"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment