why slice values can sometimes go stale but never map values?

In Go there are no reference types like you have them in C++. In Go everything is passed by value. When the term “reference type” is used in Go, it means a type that references to the data they ought to represent (via pointers). Slices are small, struct-like data structures represented by the type reflect.SliceHeader: … Read more

Swagger: map of

Using additionalPropertiesis the proper way to describe hashmap with OpenAPI (fka. Swagger) Specification but Swagger UI do not render them for now. The issue is tracked here https://github.com/swagger-api/swagger-ui/issues/1248 Meanwhile you can use this trick: define a non required property (defaultin the example below) of the same type of the map’s objects and give some hint … Read more

How to access deeply nested dictionaries in Swift

When working with dictionaries you have to remember that a key might not exist in the dictionary. For this reason, dictionaries always return optionals. So each time you access the dictionary by key you have to unwrap at each level as follows: bugsDict[“ladybug”]![“spotted”]![“red”]!++ I presume you know about optionals, but just to be clear, use … Read more

tech