How can I use a Swift enum as a Dictionary key? (Conforming to Equatable)

Info on Enumerations as dictionary keys: From the Swift book: Enumeration member values without associated values (as described in Enumerations) are also hashable by default. However, your Enumeration does have a member value with an associated value, so Hashable conformance has to be added manually by you. Solution The problem with your implementation, is that … Read more

How to get the FxCop custom dictionary to work?

If you use it inside Visual Studio… From Visual Studio Code Analysis Team Blog To add a custom dictionary to a C# and Visual Basic project is simple: In Solution Explorer, right-click on the project and choose Add -> New Item… Under Templates, select XML File, enter a name for the dictionary, such as CodeAnalysisDictionary.xml … Read more

Convert map[interface {}]interface {} to map[string]string

A secure way to process unknown interfaces, just use fmt.Sprintf() https://play.golang.org/p/gOiyD4KpQGz package main import ( “fmt” ) func main() { mapInterface := make(map[interface{}]interface{}) mapString := make(map[string]string) mapInterface[“k1”] = 1 mapInterface[3] = “hello” mapInterface[“world”] = 1.05 for key, value := range mapInterface { strKey := fmt.Sprintf(“%v”, key) strValue := fmt.Sprintf(“%v”, value) mapString[strKey] = strValue } fmt.Printf(“%#v”, … Read more

Why doesn’t Golang allow const maps?

From https://golang.org/ref/spec#Constants: A constant value is represented by a rune, integer, floating-point, imaginary, or string literal, an identifier denoting a constant, a constant expression, a conversion with a result that is a constant, or the result value of some built-in functions such as unsafe.Sizeof applied to any value, cap or len applied to some expressions, … Read more

How to create a shared editable dictionary for Intellij Idea spellchecking?

Note that, even though the words added to the dictionary by each developer are stored in a separate file, IntelliJ IDEA takes the words added by all developers, and does not highlight any of them as typos. The storage in separate files was designed specifically to avoid merge conflicts when storing the dictionary in a … 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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)