Skip to content

Instantly share code, notes, and snippets.

@jcaristy
Last active September 20, 2017 22:17
Show Gist options
  • Save jcaristy/b82aedb054cd6a3c13ebdd9fb73aec77 to your computer and use it in GitHub Desktop.
Save jcaristy/b82aedb054cd6a3c13ebdd9fb73aec77 to your computer and use it in GitHub Desktop.
[RoR: Hashes] #ruby

Hashes

# Declarar
hash_person = {"nombre" => "Juan"}
hash_person["Apellido"] = "Aristizabal"

# Acceder
nombre = hash_person["nombre"]		# Por Key
index = hash_person.key("Juan")		# Me devuelve el Key

# Metodos interesantes
hash_person.keys
hash_person.values
hash_person.length
hash_person.size
hash_person.to_a		#To an Array
hash_person.clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment