On Monday, 25 February 2019 at 12:47:47 UTC, Simen Kjærås wrote:
On Monday, 25 February 2019 at 12:37:31 UTC, Vladimirs Nordholm
wrote:
Hello.
I wish to sort an array by calling a template function on a
struct. In essence I want to do
foos.sort!("a.get!Dummy < b.get!Dummy");
but I get the error message
/dlang/dmd/linux/bin64/../../src/phobos/std/functional.d-mixin-215(215): Error: undefined identifier Dummy
Is there anyway I can get `sort` to recognise my Dummy type?
Example: https://run.dlang.io/is/9zDfdd
foos.sort!((a,b) => a.get!Dummy < b.get!Dummy);
String functions can't access the local scope, and thus can't
see Dummy. Using lambdas works. (string functions were
basically a workaround for no decent lambda syntax back in the
time when dinosaurs roamed the earth)
--
Simen
Ah, thank you for the explanation Simen!