package
Version:
v0.0.0-...-fb70a81
Opens a new window with list of versions in this module.
Published: Sep 28, 2020
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
type TreeNode struct {
Value int
Left, Right *TreeNode
}
定义一个函数 xxx 指定外部对象调用,相当于其他语言的 this.xxx()
node 为接收者 print 为调用方法
go 语言都是值传递 所以需要将指针传递进去 外部调用方依然是 node.setValue() 外部不需要再转成指针形式
要改变类型必须使用指针接收着
结构过大也考虑使用指针接收者
一致性:如有指针接收者,最好都是指针接收者
Source Files
¶
Directories
¶
Click to show internal directories.
Click to hide internal directories.