On 2012-05-04 22:05, Jakob Ovrum wrote:
On Friday, 4 May 2012 at 19:17:13 UTC, Steven Schveighoffer wrote:
This one:
Collection c = new Collection();
c = c.filter!(x => x < 3).toCollection();
filter isn't a property of c, it's a range-producing function. So I
only have to define filter once, as a range accepting, range producing
function. And any container type, as long as it can produce a range,
can use this as a pseudo method (via UFCS) to make a filtered copy of
itself.
-Steve
That's not a real example, that's pretty much the same example I
provided below the part you quoted.
Real world example:
https://github.com/jacob-carlborg/dstep/blob/master/dstep/translator/Type.d#L52
I was going to use "until" at row 59, but I couldn't figure out how to
transform the range back to a string.
--
/Jacob Carlborg