Why can't static arrays be sorted?
ag0aep6g via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Oct 6 13:11:17 PDT 2016
On 10/06/2016 09:54 PM, TheGag96 wrote:
> Interestingly enough, I found that using .each() actually compiles
> without the []
[...]
> why can the compiler consider it a range here but not
> .sort()?
each is not restricted to ranges. It accepts other `foreach`-ables, too.
The documentation says that it "also supports opApply-based iterators",
but it's really anything that foreach accepts.
Relevant piece of the source:
https://github.com/dlang/phobos/blob/08c587ead2156c85c30a2bbc18028b5967010682/std/algorithm/iteration.d#L913-L914
More information about the Digitalmars-d-learn
mailing list