-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Docs say collect will return an Array, but implementation is different #36448
Comments
In the long run, my favorite way to spell that operation is |
The place where this caught me off-guard is that this also means that list comprehensions are not guaranteed to return an |
The docstring clearly says that it returns an But there is a discussion #36106 for making |
I think the docs should be changed. It seems clear that comprehensions over StaticArrays or OffsetArrays should return arrays of a similar type, and if you really need an |
Is array comprehension documented to use |
I've always wanted the ability to have the array type that any For What is the definition of |
This is indeed almost exactly the same issue as #36106. I vote for changing the documentation to allow
Well it's not completely clear whether |
I think the current docs very strongly suggest that you don't have to return an So I agree with everyone that the docs for |
Interesting. I hadn't noticed that example. OTOH it says "If |
Yeah, it depends on the indexing of |
The docs for
collect(collection)
says that it will return anArray
(see here). The implementation, though, callssimilar(Array{T}, axes(A))
to create the container that will be returned, and that is explicitly not required to return anArray
(see here).The net effect is that for example
will not return an
Array
.I think either the docs should be updated to say that
collect
will return anAbstractArray
, or thecollect
implementation should be changed to actually always return anArray
, no matter what.It certainly would be very handy to have a function in base that one can call on a collection that guarantees that one gets an
Array
, and not some custom array type.The text was updated successfully, but these errors were encountered: