pattern matching

%u asmasm at hotmail.com
Tue Sep 6 14:05:54 PDT 2011


template factorial(int n) { const factorial = n * factorial!(n-1); }
template factorial(int n : 1) { const factorial = 1; }

i think this pattern matching or like it, can i do the same thing with regular
function

int factorial(int n) {
 return n* factorial(n-1);
return 1 ;
 }

int factorial(int n : 0) {
return 1 ;
 }

is that work?

thanks in advance


More information about the Digitalmars-d-learn mailing list