duck

Example code showing case for in break bug in unity3d JS

Sep 13th, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma strict
  2.  
  3. function Start () {
  4.  
  5.     var a=1;
  6.    
  7.     switch (a)
  8.     {
  9.    
  10.         case 1:
  11.             // works as expected
  12.             for (var b=5; b>0; b--)
  13.             {
  14.                 Debug.Log(b);
  15.                 if (b == 2) {
  16.                     break;
  17.                 }
  18.             }
  19.             Debug.Log("Boom");
  20.         break;
  21.        
  22.         case 2:
  23.             // fails to detonate!
  24.             var ts : int[] = [5,4,3,2,1,0];
  25.             for (var t in ts)
  26.             {
  27.                 Debug.Log(t);
  28.                 if (t == 2) {
  29.                     break;
  30.                 }
  31.             }
  32.             Debug.Log("Boom");
  33.         break;
  34.            
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment