3 ms·
Are you going to do the nil check in every member function though? I run into this problem with Go a lot, actually. (I'd like to make initialization of a some
by ninkendo 9y ago
Are you going to do the nil check in every member function though? I run into this problem with Go a lot, actually. (I'd like to make initialization of a some member variable optional, but checking if it's nil every time I use it becomes a pain. Not all types have useful zero values either... I'm looking at you, map.)
- axaxs 9y agoWell, in my cases I usually add an unexported 'check()' method, which is generally called by every other method that needs state. It would basically just be something of x.Z == nil {x.Z = DEFAULTZ}