Skip to content

Instantly share code, notes, and snippets.

@dherman
Created January 13, 2012 22:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dherman/1609202 to your computer and use it in GitHub Desktop.
Save dherman/1609202 to your computer and use it in GitHub Desktop.
using loop controls from within block lambdas
Mailbox.prototype.extractContents = function(contacts) {
let messages = this.messages;
loop:
for (let i = 0, n = messages.length; i < n; i++) {
messages[i].headers.forEach { |header|
if (header.isSpam())
continue loop; // the label is not strictly necessary here
let addresses = header.extractAddresses();
addresses.forEach { |addr|
contacts.add(addr.name, addr.email);
};
};
}
};
@bingomanatee
Copy link

bingomanatee commented Jan 16, 2012 via email

@grncdr
Copy link

grncdr commented Jan 17, 2012

I commented more verbosely on Isaac's gist, but in short: what about disallowing mixing of block lambda return and normal return in a single function?

@polotek
Copy link

polotek commented Jan 17, 2012

I just want to point out that this is what I mean about goto and FUD. Not that labels are true gotos, not that any form of goto is harmful. But that people will want to argue about it. We will be spending a lot of our time correcting people's misconceptions. And in the end, the consensus will be, "look just don't use labels, you don't need them if you know how to write good javascript". They are not a useful feature of javascript and they should be avoided. We've managed to do it for this long. Let's not falter now.

Yes I do realize that I'm the one that first mentioned goto. Call it a preliminary social experiment that served to fully support my hypothesis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment