简体   繁体   中英

Defining a map to arrays containing slices in Golang

In Go (golang), is it possible to define a map from strings to arrays, and in each array element I want to store a slice. Like this:

var data = make(map[string][2]Slice[]float64)

Then I want to retrieve my data, something like this:

floatValue0 = data["string-key"][0][#]
floatValue1 = data["string-key"][1][#]

data := map[string][2][]float64{"golang": {[]float64{3.14, 3.15}, []float64{3.12, 3.16}}}

fmt.Println(data["golang"][0][0])

output: 3.14

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM