Hacker News new | ask | show | jobs
by Cyph0n 1261 days ago
Why would you have a method that doesn’t touch the receiver? Refactor it into a function.
2 comments

Dereferencing isn't the only way to touch a pointer:

    func (o *myObject) isNil() bool {
        return o == nil
    }
Right, but if you’re doing a nil check, you obviously won’t be worried about nil deferences.
Either to implement an interface, or because it branches to check if the value is nil before dereferencing it
Re: the second point, see my other comment.