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 trialNicholas Rossi
5,066 PointsHow to set an id variable and initialize it with a value
In the video, I saw the instructor traverse over an array using id, but not actually declaring a variable of type id.
2 Answers
Dino Paškvan
Courses Plus Student 44,108 PointsIt is done in exactly the same way as you would with any other variable: first write the variable type (id
), then the name (thing
) and finally set it to some value (nil
in this case). Don't forget the semi-colon at the end.
Nicholas Rossi
5,066 PointsThank you Dino! I got it!