Safer casts
Janice Caron
caron800 at googlemail.com
Tue May 13 00:31:46 PDT 2008
2008/5/13 Dee Girl <deegirl at noreply.com>:
> int array[] = [1, 2, 3];
> int x = 5;
> sort!((int a, int b) { return a + x < b + x; })(array);
>
> Two questions not one ^_^
>
> 1. Is the code inside sort!() as powerful as delegate?
The code inside sort!() /is/ a delegate. It's an anonymous delegate,
but its implementation is exactly the same as a delegate with a name.
It's equivalent to
int foo (int a, int b) { return a + x < b + x; };
sort!(foo)(array);
More information about the Digitalmars-d
mailing list