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

Devansh Sanghvi
PLUS
Devansh Sanghvi
Courses Plus Student 934 Points

Can anyone help me understand the code, i have some doubts in the code. What is q1 in the first place.

Through string Interpolation the value of q1 is (1,4) but when i ask the value of q1 at the end of the switch statement it shows an error saying "use of unresolved identifier q1".

let point = (x :1 , y: 4)

switch point {

case let q1 where (point.x > 0) && (point.y > 0): print(" (q1) is in quadrant 1")

default: break

}

2 Answers

Tassia Castro
seal-mask
.a{fill-rule:evenodd;}techdegree
Tassia Castro
iOS Development Techdegree Student 9,170 Points

Hey Devansh,

It is missing the backslash of the string interpolation. Try this:

let point = (x :1 , y: 4)
switch point {
    case let q1 where (point.x > 0) && (point.y > 0): print(" \(q1) is in quadrant 1") // I added this 
    default: break
}

q1 in this case is a constant declared inside switch (case let q1).

So, the code has a constant called point that has this value (x :1 , y: 4) . When you switch point, you are trying to discover if this point is in quadrant 1 (Math concept. All numbers greater than 0 are in quadrant 1).

You can read the code like this: case point.x is greater than 0 and point.y is greater than 0 so assign those values to the constant q1. After that you use the method print to print the value of q1.