Advertisement
rotrevrep

goto/label in vala

Oct 25th, 2013
1,199
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void main () {
  2.     test (3);
  3. }
  4.  
  5. int go_to (Label label){ return label (); }
  6.  
  7. int test1 (){
  8.     print ("test1\n");
  9.     return -1;
  10. }
  11. int test2 (){
  12.     print ("test2\n");
  13.     return -1;
  14. }
  15. int test3 (){
  16.     print ("test3\n");
  17.     return 1;
  18. }
  19.  
  20. void test (int mode){
  21.     switch(mode){
  22.         case 1:
  23.             go_to (test1);
  24.             break;
  25.         case 2:
  26.             go_to (test2);
  27.             break;
  28.         case 3:
  29.             test (go_to (test3));
  30.             break;
  31.         default:
  32.         break;
  33.     }
  34. }
  35.  
  36. public delegate int Label ();
Advertisement
RAW Paste Data Copied
Advertisement