- Home /
a lower case i?
I keep seeing a lower case i in scripts. I apologize if this is a trivial question but I have to ask: what does that lowercase i mean?
And if there is any case of source for learning Syntax things like that I would love a link.
Answer by Mike 3 · Jul 16, 2010 at 04:00 PM
Nothing really, it's generally just used as a basic index/count variable from languages such as C, and moved into newer languages - very often used in for loops:
for (int i = 0; i < 10; ++i)
{
//do something using i
}
Generally (for js/c#), you should always use camel case for all variables, which is lower case for the first letter, then uppercase for the first letter in every word in the name afterwards
e.g.:
i myVariable myOtherVariable
Answer by equalsequals · Jul 16, 2010 at 03:59 PM
I assume you are referring to something like this:
for(i = 0; i < someNumber; i++)
{
//do something
}
"i" is just a variable, it is customary to call it "i" for "increment" or "int" but it can be anything. In that above code it just means:
As long as i, which starts at 0 is less than someNumber (another variable) keep firing the encapsulated code, And when it reaches the "}", end of encapsulation, increment "i" by 1 and repeat... Which is a for loop.
Hope that helps
==
Back when I learned program$$anonymous$$g years ago I was taught to think of it as integer because you are only working with a whole number. Index only makes sense if you are recursively moving through array indexes or something similar, but 'i' for int always makes sense. Alternatively since you are incrementing it, 'i' for 'increment' also makes sense. Way easier to remember in my book. :)
Your answer
Follow this Question
Related Questions
Referencing variables / functions on another script 1 Answer
Block programming for Kid 1 Answer
Deleting animation curve with editor script 1 Answer
unity web player startup 0 Answers
us of the "as" keyword (Instantiate, GetComponent) 2 Answers