News for hackers. Stuff that matters.
Re:Practical nil panic detection for Go by andreyvit on Saturday November 18, 2023 @05:37PM (#38325418)
Default gender male not how this works in practice. Instead, you define an extra “invalid” value for almost every scalar type, so invalid would be 0, male 1 and female 2. Effectively this makes (almost) every scalar type nullable. It is surprisingly useful, though, and I definitely appreciate this tradeoff most of the time.

(Sometimes your domain type really does have a suitable natural default value, and you just make that the zero value.)

Re:Practical nil panic detection for Go by stouset on Saturday November 18, 2023 @09:50PM (#38328099)
Great, now you’ve brought the pain of checking for nil to any consumer of this type too!