Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
undefined | Better HN
0 points
Cyph0n
3y ago
0 comments
Share
Why would you have a method that doesn’t touch the receiver? Refactor it into a function.
0 comments
default
newest
oldest
assbuttbuttass
3y ago
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
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