當前位置:編程學習大全網 - 網站源碼 - golang中map能嵌套map嗎

golang中map能嵌套map嗎

自然是可以的,當然map不能作為另壹個map的key,只能做value。請參考以下例子:

package?main

import?"fmt"

type?t_classmates?map[string]int

func?main()?{

domitory?:=?make(map[string]t_classmates)

class1?:=?make(t_classmates)

class1["zhangsan"]?=?23

class1["lisi"]?=?24

domitory["308"]?=?class1

domitory["309"]?=?t_classmates{"wangwu":?25,?"zhaoliu":?26,}

fmt.Println(domitory)

}

  • 上一篇:華為鴻蒙繼續開放:方舟JS運行時正式開源
  • 下一篇:婚慶布場隔夜後的鮮花怎樣保鮮呢?特別是新娘手中的那束花保鮮很重要,本人很是苦惱啊!
  • copyright 2024編程學習大全網