Skip to content
Better HN
Top
Best
Ask
Show
New
Jobs
Search
⌘K
0 points
Cyph0n
3y ago
0 comments
Save
Share
Why would you have a method that doesn’t touch the receiver? Refactor it into a function.
0 comments
4 comments · 2 top-level
top
newest
oldest
assbuttbuttass
3y ago
· 1 in thread
Dereferencing isn't the only way to touch a pointer:
func (o *myObject) isNil() bool { return o == nil }
Cyph0n
OP
3y ago
Right, but if you’re doing a nil check, you obviously won’t be worried about nil deferences.
remexre
3y ago
· 1 in thread
Either to implement an interface, or because it branches to check if the value is nil before dereferencing it
Cyph0n
OP
3y ago
Re: the second point, see my other comment.
j
/
k
navigate · click thread line to collapse