Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Could someone explain me about the index
I understand its purpose, but what does it mean/ how is it used in arrays. (swift) Actually, could you just explain what the index is/ how it is used... in short, can someone just explain to me what the index is....
Hi Egor. Just to be clear - index without context is a very loose concept... There is no "the index" if not in a specific context.
Normally, however, "index" is used to describe a pointer to a specific spot/row/item/whatever in an ordered list. I am using very broad terms here... It could be a value in an array or a row in a table - as long as there can be many items in an ordered fashion you use an index to specify which item/row/etc you are interested in.
var array = ["First Item", "Second Item", "Third Item"]
The array above has three items and you can access each of them using an index. In all programming languages (that I am aware of) basic enumeration begins with index 0. So to get the first item you would say array, and to get the second array etc. etc. Makes sense?
A index is a position in a array. Say you have a array of colors var colorsArray = ["red", "blue", "gray", "orange"]
Okay now to get the index position for blue you need to call it like this println(colorsArray) <----it's index 1 because index starts at 0 position
Hope this helps.