我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

你叫(* receiverType).method(receiver)?

I recently learned that you can invoke a receiver's method by doing (*receiverType).method(receiver), where the first parameter is always the receiver itself.

func main() {
    c := &Cool{}
    c.say("Cool!")
    (*Cool).say(c, "Hot!") // <-- this
}

type Cool struct {
}

func (it *Cool) say(s string) {
    fmt.Println(s)
}

https://play.golang.org/p/vVjr42ceqA

Is there a name for this kind of syntax? Why does this compile?

近期文章

  • 为Tensorflow构建Go绑定时出错
  • 找不到软件包“ testing / internal / testdeps”
  • 选择嵌套数组对象-Mgo
  • 我可以期望(要求)通过测试失败吗?
  • 我们可以将额外的参数传递给beego路由器吗
  • 追加中不能使用****文字(****类型)作为struct {}类型
  • 使用GoLang http.FileServer时找不到React脚本
  • 使用Go在App Engine上进行GORM Cloud SQL连接
  • Docker服务更新错误:EOF
  • go get在依赖项中找不到导入文件
  • Goswagger没有创建适当的JSON规范文件
  • ESP32-cam 虚拟机官方环境开发 make flash monitor时出出现错误。
  • matlab.两物种简单生态系统均衡状态
  • 为什么 jupyter得到的绘图与指定子图行,列,编号不符合?
  • Qt对拥有2亿行字符串的文本文件进行排序?
  • 使用golang中的时间戳将紧急输出重定向到文件
  • 扩展组成的Go Struct的标签
  • 错误超时获取HTTP请求golang
  • Golang FTP EPRT错误
  • 在Go中按请求管理连接

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华