Why can't static arrays be sorted?
    TheGag96 via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Thu Oct  6 12:54:57 PDT 2016
    
    
  
On Wednesday, 5 October 2016 at 19:30:01 UTC, Jonathan M Davis 
wrote:
> It doesn't even make conceptual sense for a static array to be 
> a range, because you can't remove elements from it.
>
> - Jonathan M Davis
Interestingly enough, I found that using .each() actually 
compiles without the [] but (as expected) creates a copy... So, 
these output different values:
   thing.each!((ref x) => writeln(&x));
   thing[].each!((ref x) => writeln(&x));
Should there me a more consistent behavior here? Even if the 
behavior is pretty undesired, why can the compiler consider it a 
range here but not .sort()?
    
    
More information about the Digitalmars-d-learn
mailing list