hash table

package main

import (
    "fmt"
)

func main() {
    hashMap := make(map[string]int) // Step 1: Create an empty hash map using the make function with string keys and integer values

    hashMap["apple"] = 5             // Step 2: Add a key-value pair "apple" with value 5 to the hash map
    hashMap["banana"] = 3            // Step 3: Add a key-value pair "banana" with value 3 to the hash map

    value, exists := hashMap["apple"] // Step 4: Check if the key "apple" exists in the hash map and retrieve its value
    if exists {
        fmt.Println("Value of apple is:", value) // Step 5: Print the value associated with the key "apple"
    }

    delete(hashMap, "banana")        // Step 6: Delete the key "banana" from the hash map

    _, exists = hashMap["banana"]    // Step 7: Check if the key "banana" still exists in the hash map after deletion
    if exists {
        fmt.Println("Value of banana is:", hashMap["banana"]) // Step 8: This won't be executed as "banana" key is deleted
    } else {
        fmt.Println("Banana is not in the map anymore") // Step 9: Print a message indicating that "banana" is no longer in the map
    }
}