3 ms·
It should be noted that nil in Go is not quite[1] the same as null in C though. For example, if a method defines the return type as a value (say, a string), you
by stock_toaster 13y ago
It should be noted that nil in Go is not quite[1] the same as null in C though. For example, if a method defines the return type as a value (say, a string), you cannot validly return a nil (compile error).
[1]: http://blog.denevell.org/golang-null-nil.html
- masklinn 13y agoEr… similar code in C: struct foo bar () { return NULL; } is a compilation error as well… (granted it's not an error for strings because C has no strings per-se)
- stock_toaster 13y ago> (granted it's not an error for strings because C has no strings per-se) That was kind of the entire point though.
- masklinn 13y agoSay what? Your statement is that Go's nil is different than C's null. As demonstrated, it is not, C's null is for pointers and Go's nil is also for pointers. The difference is that Go has a value-type string and C does not, but that is only a parenthesised aside in your original comment (as an example of Go value types), nowhere near "the point" let alone "the entire point".