Prototype Try.these

Läste lite om JavaScript biblioteket Prototype och hittade att det tillför en funktion som heter try.these och ett exempel kan se ut så här:

return Try.these(
function() {
alert("first");
jkgjhgjhg        //intentional error
alert("firsterror");
return 1;
},
function() {
alert("second");
return 2;
}
);

Där den helt enkelt testar olika block av kod och om det blir fel så testar den nästa.
Det ger en helt ny tolkning av “trial and error”. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.