4 ms·
>range does not work with user-defined types at all that's close to true but not strictly true, since you can define your own types using slices, maps and chan
by zemo 13y ago
>range does not work with user-defined types at all
that's close to true but not strictly true, since you can define your own types using slices, maps and channels. The reason you would do that is that by defining your own type, you can give a slice, map, or a channel type a method set, which by extension means that you can create a slice, map, or channel that satisfies an interface. E.g.: http://play.golang.org/p/04IBK5OwNk http://play.golang.org/p/04IBK5OwNk
>While interesting new control flow is unlikely to be a headline item on a newly developed language these days
...ummm, goroutines? I know that's not "new" in the sense that CSP has been around since the 70's, but the `go` keyword is a new control flow mechanism for many programmers. Concurrency is a control flow concept.
- munificent 13y ago> Concurrency is a control flow concept. Couldn't agree more. Also a list of all flow control constructs that doesn't include destructuring pattern match ain't a complete list in my book. if and switch are just special degenerate cases of pattern-matching.