2 ms·
they are so pervasive/important that it should be included in the core library. I'd include my own collection_utils every single time. That said, having a libr
by alkonaut 12y ago
they are so pervasive/important that it should be included in the core library. I'd include my own collection_utils every single time.
That said, having a library function of course requires it to work in a type safe way for all collections/functions, which might make this argument really be one about generics and not about two collection functions. If this is omitted because generics is, I think it's just another argument why omitting generics is making the language simple to the point of being stupid.
- NateDad 12y agoInstead of map/filter: // using some fake filter/map/lambda syntax names := machines.filter(strings.HasPrefix(m.tag, "ec2")).map(|m| = m.name) why not just write names := []string{} for _, m := range machines { if strings.HasPrefix(m.tag, "ec2") { names = append(names, m.name) } } What happens when you read that first implementation? Don't you read it as "for each machine, if its tag has the prefix "ec2", then append its name to the list that is returned? Isn't that the exact same thing you'd read the second one as? Except that the second one requires no special knowledge other than loops and if statements.