Last active
April 26, 2019 15:45
-
-
Save igomez10/456f4953965400ac9191ffc953fdac05 to your computer and use it in GitHub Desktop.
Generic data structure in Go
This file contains 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" | |
type hack struct { | |
value interface{} | |
} | |
func main() { | |
threeInOne := [3]hack{} | |
threeInOne[0].value = []string{"hello"} | |
threeInOne[1].value = 1 | |
threeInOne[2].value = func(par interface{}) { fmt.Printf("%+v", par) } | |
for i := range threeInOne { | |
fmt.Println(threeInOne[i]) | |
} | |
threeInOne[2].value.(func(interface{}))("hey") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment