Created
May 31, 2016 20:39
-
-
Save cvvs/ddf4b81dc92f71c54f495d85532634cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
var stringSet map[string]interface{} = make(map[string]interface{}) | |
stringSet["apple"] = nil | |
stringSet["orange"] = nil | |
stringSet["cherry"] = nil | |
// O(1) vs O(n). Only matters for large lists | |
if _, ok := stringSet["apple"]; !ok { | |
fmt.Println("apple not in stringset") | |
} | |
if _, ok := stringSet["banana"]; !ok { | |
fmt.Println("banana not in stringset") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment