On 08.06.2017 03:57, Andrew Edwards wrote:
Ranges may be finite or infinite but, while the destination may be unreachable, we can definitely tell how far we've traveled. So why doesn't this work?

import std.traits;
import std.range;

void main()
{
     string[string] aa;

     // what others have referred to as
     // standard sort works but is deprecated
     //auto keys = aa.keys.sort;

     // Error: cannot infer argument types, expected 1 argument, not 2
     import std.algorithm: sort;
     auto keys = aa.keys.sort();

     // this works but why should I have to?
     //import std.array: array;
     //auto keys = aa.keys.sort().array;

     foreach (i, v; keys){}
}

If I hand you a chihuahua for grooming, why am I getting back a pit bull? I simply want a groomed chihuahua. Why do I need to consult a wizard to get back a groomed chihuahua?
You are not giving away the chihuahua.

auto keys = aa.keys;
sort(keys);
foreach(i,v;keys){}

Reply via email to