-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add Enumerable(T)#to_a(& : T -> U) forall U
#12653
Add Enumerable(T)#to_a(& : T -> U) forall U
#12653
Conversation
Analogous to `Enumerable(T)#(& : T -> Tuple(K, V)) forall K, V` except producing an Array from the block's result. Resolves crystal-lang#12643
Also it is probably worth documenting that |
Strange, that's what Array already does. I'm surprised when Indexable was introduced this optimization wasn't also done.
Why not? |
If you immediately insert an element to the returned array then a reallocation is guaranteed to happen and that is less performant than the default reallocation strategy on average. This is why we didn't pursue #10075 |
Analogous to
Enumerable(T)#(& : T -> Tuple(K, V)) forall K, V
except producing an Array from the block's result.Resolves #12643