doutuo4285 2014-05-16 03:54
浏览 9
已采纳

如何在go中创建配对类型?

I want to create a pair such as pair(string, int). I know that in go there is no pair type, and I also know that slices can only hold the same data type.

How may I do this?

  • 写回答

1条回答 默认 最新

  • doujie7346 2014-05-16 03:57
    关注

    Go doesn't have tuples like some other languages. You can create a struct type with a string and an int field:

    type myStruct struct {
        str string
        num int
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥25 关于##爬虫##的问题,如何解决?:
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误