-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add IterableMixin<E>#groupBy #11159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Added Area-Library, Triaged labels. |
So you are asking for: Removed Type-Defect label. |
Sounds ok. Added this to the Later milestone. |
This comment was originally written by demis.b...@gmail.com A more functional 'order', 'group', 'join', 'joinGroup', 'range' https://github.com/dartist/101LinqSamples I found it's really limiting only being able to use the functional utils that's shipped in the core libs. Most languages (JS, Ruby, C#, Scala, Clojure, Go, etc) allows us to extend or at least 'visibly extend' built-in types without our own custom methods. Dart's lack of 'extension methods' is really behind other languages in this regard, which visibly affects the surface area of the API impacting readability since we're unable to idiomatically chain transformation methods. |
Removed this from the Later milestone. |
Removed Oldschool-Milestone-Later label. |
Adding new members to Iterable at this point is not a good idea. Removed Ready-to-implement label. |
This comment was originally written by bl...@google.com So where should they be added instead then? |
This comment was originally written by @mezoni
As workaround you can use package "queries": ================ void main() { void dipslay(Collection data) { Output: ================ It sometimes even slightly faster than Dart <Iterable>. |
Added NotPlanned label. |
Sorry for bringing this back up. What are the chances of this being resurrected? Or what needs to happen in order to get this back in the "Planned" list? |
Depends on what we are allowed to change for Dart 2.0. So, an solution at this point would be adding a separate groupBy(Iterable elements, key(element)) function to, say, package:collection, or using one of the other packages that implement similar functionality. |
Thanks @lrhn for the details! I understand that dealing with breaking changes may be very difficult. What I wanted to point out is that there is one thing (among others) which is done very well in Dart - it is standardizing of best practices in programming languages and implementing them in the Dart language itself or the standard library. And that's what people refer to a lot when talk about Dart - especially when talk about Futures, Streams and await/async. There is only one way to work with Futures or Streams and it enables great interoperability between all the packages built by the community. And that is a huge benefit. I think collections library in the core is also one of such features. Things like groupBy are pretty common and there is already number of packages which introduce their own implementations (queries, dict, dartmixins, to name a few). And this number is going to grow, people will come up with more and more implementations. I think even this proposal:
is a lot better then relying on the army of other packages. However maybe there is a better way to deal with this? Maybe introduce gradual deprecation policy consisting of several steps like:
Of course, I'm not saying this is the way to go (or practically possible) since I'm not familiar with the development process in the Dart team. But I also can't see in this thread that this issue has been given enough attention. Regardless I still believe the Dart team has been really great in carefully designing every little piece of the language and the sdk. But maybe this issue deserves to get another round. |
Java 8 solved the problem of new methods in API with default methods. It could be useful to have something similar in Dart to avoid needing a breaking change if you want to add a method. |
This issue was originally filed by @MarkBennett
What steps will reproduce the problem?
What is the expected output? What do you see instead?
A groupBy function should exist which transforms an iterable in to a HashMap where the keys are the common value. It's possible a mapping function could be used to transform the original values before they are grouped.
What version of the product are you using? On what operating system?
Mac OS, Dart SDK 23552
Please provide any additional information below.
This came up during a weekend CodeRetreat when I was pairing with a C# dev, then again when reviewing https://github.com/dartist/101LinqSamples
The text was updated successfully, but these errors were encountered: