February 25, 2006

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". :)

Posted by peppar at February 25, 2006 03:49 PM in Techstuff
Comments
Post a comment









Remember personal info?