From Aqua Stork, 1 Year ago, written in Plain Text.
Embed
  1. auto Correct(int i) {
  2.   if (i == 1)
  3.     return i;               // return type deduced as int
  4.   else
  5.     return Correct(i-1)+i;  // ok to call it now
  6. }
  7.  
  8. auto Wrong(int i) {
  9.   if (i != 1)
  10.     return Wrong(i-1)+i;  // Too soon to call this. No prior return statement.
  11.   else
  12.     return i;             // return type deduced as int
  13. }