logoalt Hacker News

skydhashyesterday at 12:58 PM2 repliesview on HN

I like go’s approach on having default value, which for struct is nil. I don’t think I’ve ever cared between null result and no result, as they’re semantically the same thing (what I’m looking for doesn’t exist)


Replies

onionisafruityesterday at 1:37 PM

In Go, the default (zero) value for a struct is an empty struct.

Cyph0nyesterday at 1:47 PM

Eh, it’s not uncommon to need this distinction. The Go convention is to return (res *MyStruct, ok bool).

An Option type is a cleaner representation.