3 ms·
> The worst example is pointers since they're used to represent both references and optional values. using a pointer as an optional value is an anti-pattern. c
by 38 2y ago
> The worst example is pointers since they're used to represent both references and optional values.
using a pointer as an optional value is an anti-pattern. correct idiom is to return a tuple:
type positive struct{}
func new_positive(i int) (*positive, bool) {
if i >= 0 {
return positive{}, true
}
return nil, false
}