On Sat, Jan 10, 2009 at 11:26:50PM +0300, Richard Hainsworth wrote:
> More precisely, I dont understand the meaning of the ':' after '.sort'

It is turning the method call into a list operator, essentially.
It's not the so-called indirect object syntax, or it would be written:

    my @ranking = sort %players: { .value };

But the idea is related, and has a similar effect.  If you're familiar
with Haskell, it's a bit like the $ operator in working like an opening
parenthesis that needs no closing parenthesis.

Yet another way to write the sort is

    my @ranking = %placers.sort :{ .value };

but in this case, the colon is introducing an adverb which modifies
the previous operator, which happens to be sort.  The difference
is that you can't continue the argument list after that, except
with more adverbs, whereas with the list operator form, the block
is merely the first argument:

    my @ranking = %placers.sort: { .value }, $some, $extra, $args;

(Not that sort would know what to do with extra args, but we're talking
about generic syntax...)

Larry

Reply via email to