Does this for loop end once it returns an object?

So I have a bug that I’m trying to track down. I’m firing all my bullets at the same time and I’m wondering if it is because of this for loop. Once I return an object does this for loop end or do it keep going til it hits the end of the list?

    public GameObject GetPooledObject() {
		for (int i = 0; i < _pooledObjects.Count; i++) {
			if (!_pooledObjects*.activeInHierarchy) {*

return pooledObjects*;
_
//Once this is returned does this for loop continue til the*

//end of the list?
* }*
* }*
* if (willGrow) {*
* GameObject obj = (GameObject)Instantiate(objectToPool);*
* pooledObjects.Add(obj);
_
return obj;*

* }*
* return null;*
* }*

Returning from a function means ending what you were doing in it. The first applicable result will be what is returned.

However, that doesn’t mean that you can’t necessarily return multiple if needed, but that would simply mean that you could make a variation of your function which returns a GameObject array after populating it inside the function instead.

public GameObject[] GetPooledObjects() {
    // Build new array from valid gameObjects,
    // then return the whole array.

Edit: Or your function call itself could call the objects in the array individually by passing an array element as a parameter.

public GameObject GetPooledObject(int element) {
    if (!_pooledObjects[element].activeInHierarchy) {
    // ...

No. The for loop returns only the first GameObject of your list and then stops.

To return multiple gameobjects you would have to call this function several times with some specific parameters or define the function as an array (or list) of GameObjects.

“return” marks the end of your function, and with it the loop. So that’s not where your bug is coming from.

If you’re curious about it, just put a Debug.Log in after the return and see for yourself.