Mutables

    Go

    1. package main
    2.  
    3. import (
    4. "fmt"
    5. "strings"
    6. )
    7.  
    8. thing[index] = strings.ToUpper(thing[index])
    9. }
    10.  
    11. func upone_map(thing map[string]string, index string) {
    12. thing[index] = strings.ToUpper(thing[index])
    13. }
    14.  
    15. func main() {
    16. // mutable
    17. upone_list(list, 1)
    18. fmt.Println(list) // [a B c]
    19.  
    20. // mutable
    21. dict := map[string]string{
    22. "a": "anders",
    23. "b": "bengt",
    24. }
    25. upone_map(dict, "b")
    26. }