for loop question

What is the short form of this

for (i=0;i<n;i++){
dosomethingwith i

}

something like
for(i in x)???
I saw something like this in some scripts a while back but can’t remember the exact form.

Thanks,

Dan

The second is not a short form of the first. The second format you mention is the javascript equivalent of a “for each” statement, used to easily iterate over an array.

That will give you the value i from 0 to n. So its a number.

If you want to travers say an array list of items you could use

foreach (Item anItem  in m_allMyItems)
 {

  Debug.Log(anItem.name);

 }

or

for ( int i = 0; i < m_allMyItems.count ; i++)
{

Debug.Log(m_allMyItems[i].name);


}

These are c# by the way