On Jun 17, 2020, at 8:45 PM, Ian Lance Taylor <i...@golang.org> wrote: > > On Wed, Jun 17, 2020 at 9:35 AM <hunterlher...@gmail.com> wrote: >> >> How do I write a function that can take any container? Either a built in >> container or a user defined structure? Java is awkward when deciding to >> accept arrays or the List type — is go fated to repeat this awkwardness? > > It is as you fear: Go does not have a unified syntax for looping over > either builtin containers or user containers. In Go this rarely comes > up due to the absence of generics.
I might object to the use of "rarely" here: there's no convenient construct in Go to iterate over any non-fixed container but a channel, and while you can make an iterator/generator out of a channel, it is awkward and fraught with peril because of some of the peculiarities around hanging channels. This comes up rather a lot for me, actually. - Dave -- 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/0DA952D0-4C74-424B-849A-54A15D600766%40gmail.com.