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 trial

iOS Swift Basics (retired) Collections Modifying an Array

weixin yang
weixin yang
312 Points

Can you only assign string in array or variable too

Can you only assign string in array or variable too.

Michael Pastran
Michael Pastran
4,727 Points

yeah you can assign both into an array.

let array [1,2,3]

or

let array ["One", "Two", "Three']

1 Answer

Yes, you can actually assign both in the same array as well, for example var cat = [1,"dog","mouse"]

when you print cat it comes out as "[1, string, peace, 234]"

You can do all of what he did in this video with the array I mentioned above as well.