Changes between Version 1 and Version 2 of ReturnExample
- Timestamp:
- 01/23/06 08:48:24 (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ReturnExample
v1 v2 11 11 {{{ 12 12 #!d 13 /* 14 Return exits a function. 15 If it's not a void function return allows you to return a value. 16 */ 13 /* Return exits a function. 14 * If it's not a void function return allows you to return a value. 15 */ 17 16 18 void f1() 19 { 20 printf("Running f1...\n"); 17 import std.stdio; 18 19 void f1 () { 20 writefln("Running f1..."); 21 21 } 22 22 23 void f2() 24 { 25 bit itsAGoodIdea = true; 23 void f2 () { 24 bit itsAGoodIdea = true; 26 25 27 printf("Running f2...\n");26 writefln("Running f2..."); 28 27 29 if(itsAGoodIdea)30 {31 f1();32 return;33 } 34 printf("Don't go there.\n");28 if(itsAGoodIdea) { 29 f1(); 30 return; 31 } 32 33 writefln("Don't go there."); 35 34 } 36 35 36 void main () { 37 f2(); 38 writefln("The end."); 39 } 40 }}} 37 41 38 39 void main() 40 { 41 f2(); 42 printf("The end.\n"); 43 } 44 45 /* 46 47 Output: 48 42 == Output == 43 {{{ 49 44 Running f2... 50 45 Running f1... 51 46 The end. 52 53 */54 47 }}} 55 56 == Source ==57 58 || Link || http://www.dsource.org/tutorials/index.php?show_example=92 ||59 || Posted by || jcc7 ||60 || Date/Time || Sat May 22, 2004 1:45 pm ||