On Thu, Aug 20, 2020 at 10:40 PM burak serdar <[email protected]> wrote:
> What worries me is code like this:
>
> func f() any {
> int *i
> return i
> }
>
> func main() {
> if f()==nil {
> ...
> }
> }
>
> Use of "any" makes it look like f returns an *int and f() is nil, but
> it is not, because "any" is interface{}.
>
> I think "any" as a constraint is useful, like "comparable", but "any"
> as a type is misleading.
>
Isn't your example just a case of confusing a nil interface with a nil
value inside a generic interface? How does requiring writing it as `func
f() interface{} {` make the behavior any clearer?
--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD9vxUXrKHpRtFwB0nvLvnqP1eOryAQi6TuhT00RM0LBMw%40mail.gmail.com.