// Sometimes you end up typing this having to return // a value you made up but don't care about. func f1() (int, error) { return -1, errors.New("something went wrong") }
// Or maybe like this with named return values. func f2() (a int, err error) { return a, errors.New("something went wrong") } // It would be nice if you could type this instead. // // The underscore being used here to return whatever is in // the return slot when the return statement is executed. func f() (a int, err error) { return _, errors.New("something went wrong") } The last doesn't compile of course, it gives cannot use _ as value or type Being able to use _ seems like a nice convenience to me. What it actually returns is completely defined. And it would save us having to figure out types for stuff that you can't use `nil` for, eg `time.Time` is particularly annoying. Thoughts? Play: https://go.dev/play/p/TeNMV9zWemg -- 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/ce73e522-fa63-4493-9376-daa16848b3c0n%40googlegroups.com.