Ruby by Example / Hash
teams = {
teamA: 12,
teamB: 15,
}
puts teams["teamA"]
teams.each do |key, value|
puts "#{key}:#{value}"
end
12
teamA:12
teamB:15
Insert
teams["teamC"] = 1
Delete
teams["teamA"] = nil
teams = {
teamA: 12,
teamB: 15,
}
puts teams["teamA"]
teams.each do |key, value|
puts "#{key}:#{value}"
end
12
teamA:12
teamB:15
Insert
teams["teamC"] = 1
Delete
teams["teamA"] = nil