Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialHans Lohmann
414 PointsI'm work with lists in arrays, and I need to add an item.
This is a 3 part question I got the other 2 parts correct, its just the last part I wrote I couldn't get correct, I wrote what I thought it should be, here is a screen shot, tell me what you think. Thanks
2 Answers
Meek D
3,457 PointsIf you want to add more items to an array, you just need to call .insert method for example
var name = [String]()
name.insert("My_Name", atIndex: 0)
So now the name array has a new item at index 0. Hope that helps
Hans Lohmann
414 PointsOk I voted it the best answer. So I write "@"MeekD and where where exactly do I write this. Plus did I write it correctly??
Meek D
3,457 Pointsin the comment box type @ then type the person name
Hans Lohmann
414 PointsHans Lohmann
414 PointsI just tried what you mentioned and I it did't take that. I think its a simple solution, but I can't figure out how to solve it. Any more suggestions let me know. Thanks
Meek D
3,457 PointsMeek D
3,457 PointsI gave you an example not the answer.But the answer is todo.insert("Learn Ios", atIndex: 1)
Hans Lohmann
414 PointsHans Lohmann
414 PointsThanks, this is what I came up with, I still didn't get it, but i think I may have forgotten a period. I'm going to look at it again in a second.
Hans Lohmann
414 PointsHans Lohmann
414 PointsI didn't see what you just wrote until I did the work myself I got the same thing you wrote, but it didn't accept it. Hmmm, maybe its a small typo that I'm not seeing. I believe it is a minor mistake and think I will move on and look at it again in more detail later. Nice meeting you I'm from Ct. Have a good day.
Meek D
3,457 PointsMeek D
3,457 PointsGlad to help you if anything just tag my name into a post .. if you are having problem
Hans Lohmann
414 PointsHans Lohmann
414 PointsI just re-typed it and it worked the first time. I must have had a typo or something. How do I tag your name as you mentioned if I have a question in the future.
Meek D
3,457 PointsMeek D
3,457 PointsThis "@" + type my name .. And also vote this post as the best answer if it helps you.
Hans Lohmann
414 PointsHans Lohmann
414 Pointsok I tried that another question I had which I solved let me know if you got it.