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 trialJaskirat Singh
1,652 PointsWhat?
What is wrong With THIS?
var shoppingList: [String] = ["toothpaste", "bread", "eggs"]
var cart = shoppingList.removeAtIndex[1]
4 Answers
Caleb Kleveter
Treehouse Moderator 37,862 PointsGetting rid of removeAtIndex will solve the problem:
var cart = shoppingList[1]
Josh Gonet
5,602 PointsHI Jaskirat. I believe it's because the 1 after 'removeAtIndex' needs to be in regular brackets instead of square brackets. Change that and see if it helps!
Josh
Jaskirat Singh
1,652 PointsIt says
Bummer! You need to use subscripting to access the array element.
Josh Gonet
5,602 PointsWhich value are you trying to remove: toothpaste, bread or eggs?
Jaskirat Singh
1,652 Pointsif you click on data_collections on top of the code I wrote on the top, it will take you to the challenge. I am getting stuck at the 2nd task
Jaskirat Singh
1,652 PointsJaskirat Singh
1,652 PointsIt worked! can you please briefly explain me how that is the subscripting method?, or why that is working and what I did is not?
Caleb Kleveter
Treehouse Moderator 37,862 PointsCaleb Kleveter
Treehouse Moderator 37,862 PointsNot really. In the challenge instructions it says to 'Using array subscripting'. When you use removeAtIndex though you get an error in the preview that says:
So I don't think that once you removing 'removeAtIndex' you are subscripting. I might be wrong though.
Jaskirat Singh
1,652 PointsJaskirat Singh
1,652 PointsOkay, Thanks!