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) Control Flow If Statement

What type is cards when it's declared as a constant?

When Amit declares

let cards = 

what is its type?

3 Answers

Stone Preston
Stone Preston
42,016 Points

amit types

let cards = 1...13

using the ... syntax creates a range, so cards is a constant of type range.

Hey Jeremy,

that isn't valid swift code, nor would something like this ,

let cards

if you do what you said Xcode says "expecting initial value after '=' ". so I'm not sure what you means because the code you said ins't valid.

Best, Kai

Ok as stone says, the 1...13 make a range.

Mike Atkinson
Mike Atkinson
6,882 Points

In Xcode, if you hold option and click on where you declare "cards", it will tell you:

declaration: let cards = Range<Int>

So, the type would be a range, specifically a range of integers.