How to use UFCS and std.algorithm.sort?
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Mar 10 11:16:04 PDT 2015
On 03/10/2015 01:40 AM, Jonathan M Davis via Digitalmars-d-learn wrote:
> .sort on an array is going to use the built-in sort property. You need to
> use parens if you want to use the function in std.algorithm with an array
> and UFCS, e.g.
>
> arr.sort();
Didn't know that. Nice!
Another option is to use renamed imports[1] but it is hard to come up
with an acceptable name other than sort:
import std.algorithm: algSort = sort, uniq, map; // <-- HERE
// ...
string[] result = arr
.map!(n => n) // minified
.array
.algSort // <-- HERE
.uniq
.array;
Ali
[1] http://dlang.org/module.html
More information about the Digitalmars-d-learn
mailing list