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 reverse a Map in Kotlin?

Since the Map consists of Entrys and it is not Iterable you can use Map#entries instead. It will be mapped to Map#entrySet to create a backed view of Set<Entry>, for example: val reversed = map.entries.associateBy({ it.value }) { it.key } OR use Iterable#associate, which will create additional Pairs. val reversed = map.entries.associate{(k,v)-> v to k} …

Read more

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

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