News for hackers. Stuff that matters.
Re:Trying Out Generics in Go by ipsi on Thursday December 16, 2021 @06:16PM (#29585362)
You're sort of forced to handle them, in that if a function returns (Data, error), you need to assign the error to a variable (or do data, _ := func(), but at least that indicates you're intentionally ignoring the error), and since Go treats unused variables as a compile failure, you might as well check them properly. But there's nothing that says you must check them, no.
Re:Trying Out Generics in Go by xxpor on Friday December 17, 2021 @12:58PM (#29595722)
Ah thanks, that's kind of what I thought. I've read examples of Go but haven't written a line of it myself. the way GP described it made it sound like foo, err = bar() was merely a convention and you could do foo = bar() and drop err. If you have to add ", _" that's fine.