3 ms·
Sure, pointers are nullable types, but they also are necessary for mutability, so you're forced to use them for non-nullable things too. You'll notice the go s
by TheDong 3y ago
Sure, pointers are nullable types, but they also are necessary for mutability, so you're forced to use them for non-nullable things too.
You'll notice the go stdlib uses pointers for things which absolutely should not be nullable types, like '(*big.Int).Add(*big.Int, *big.Int)', or 'time.NewTimer() *time.Timer'.
'time.NewTimer' will never return a nil. 'big.Int.Add(x, y)' requires all of those things to be non-nil.
However, those are all pointers for unrelated reasons, like mutability, and so clearly pointers are not _just_ "nullable types".