What is a foreach loop?

Al Heck
Aug 11, 2021

--

Very similar to a for loop, but the declaration is different. We create a var named item and we search inside the array of itemName. To do that, we write it like this:

We can then do an if statement inside and do a simple search — look inside item for this particular item.

They are identical to for loops, but with a cleaner sintax

--

--

Al Heck

Unity Developer and Software Engineer who loves making games with GameDevHQ