Hacker News new | past | comments | ask | show | jobs | submit login

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



Er… 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)


  > (granted it's not an error for strings because C has no strings per-se)
That was kind of the entire point though.


Say 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".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: