Ruby Hashes
Ruby Hashes
Creating a Hash
You can create a hash using curly braces {} or the Hash.new method:
Example:
person = { name: "Alice", age: 30, city: "New York" }
# Accessing a value
puts person[:name] # Output: Alice
# Adding/updating
person[:email] = "[email protected]"
person[:age] = 31
# Deleting a key
person.delete(:city)