foreach, an analogy

Jarrett Billingsley kb3ctd2 at yahoo.com
Wed Oct 18 21:07:15 PDT 2006


"Bill Baxter" <dnewsgroup at billbaxter.com> wrote in message 
news:eh6rva$1anj$2 at digitaldaemon.com...

> I think it may be Ruby blocks.

They're just anonymous functions which happen to come after the function 
call's closing paren.. I wouldn't really say that they're incredibly 
earth-shattering or the answer to everything.  And D can almost do them 
already.  Instead of:

something.each do |item|
    puts item
end

You can have:

something.each((int item) {
    writefln(item);
});

In fact the "allowing a trailing function literal" has been proposed (by 
myself included), which would allow:

something.each()(int item)
{
    writefln(item);
}
// maybe there'd need to be a semicolon here?

Which is damn close if you ask me. 





More information about the Digitalmars-d-announce mailing list