dqtiober37522 2018-06-02 15:50
浏览 30
已采纳

如何通过[] * type函数?

I have a method in Golang that requires a []*type as a parameter.
I have a slice:

s := make([]myType, 3)

How do I do that?

  • 写回答

1条回答 默认 最新

  • duangang2825 2018-06-02 19:15
    关注

    In short (and as somewhat alluded to by other commenters), it sounds like you're asking how to use a feature that Go doesn't support. Namely, generics: a function with signature []*type, where type isn't actually a specific concrete type that you've already defined. While this might be supported in the future, it isn't for right now - you're stuck with defining the function with []*specific-concrete-type for now.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao