Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted I can't figure out with my 'array is filled' routine isn't working

Discussion in 'Scripting' started by davidnibi, Apr 8, 2021.

  1. davidnibi

    davidnibi

    Joined:
    Dec 19, 2012
    Posts:
    329
    Code (CSharp):
    1.     bool IsArrayEmpty ()
    2.     {
    3.         for (int i = 0; i < pickupHandleComplete.Length; i++)
    4.         {
    5.             if (pickupHandleComplete[i])
    6.             {
    7.                 return true;
    8.                 print ("TRUE");
    9.             }
    10.         }
    11.         return false;
    12.         print ("FALSE");
    13.     }
    I run this with:

    Code (CSharp):
    1. allFree = IsArrayEmpty ();
    When pickupHandleComplete is 'filled', it should return true. But it doesn't seem to process it, and I'm getting

    Code (CSharp):
    1. warning CS0162: Unreachable code detected
    For my print test statements
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    13,753
    Both of your print statements are AFTER a return statement so... not reachable!
     
unityunity