How to use UFCS and std.algorithm.sort?
Jonathan M Davis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Mar 10 01:40:20 PDT 2015
On Tuesday, March 10, 2015 07:24:52 Andre via Digitalmars-d-learn wrote:
> Hi,
>
> with the new beta I get the warning I should use
> std.algorithm.sort instead the .sort property. I thought the
> std.algorithm.sort method is used in this example?
>
> void main()
> {
> import std.algorithm: sort, uniq, map;
> import std.array: array;
>
> string[] arr = ["A","B","B","C"];
>
> string[] result = arr
> .map!(n => n) // minified
> .array
> .sort
> .uniq
> .array;
> }
>
> I want to use the sort template with the default less "a < b"
> without specifying !("a < b")
.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();
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list