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 trialJose Patarroyo
2,953 Pointschallenge 1 Protocols doesn't work
why isnΒ΄'t it working. The challenge was: Declare a protocol named UserType. The protocol defines two requirements: a gettable property named name of type String, and a gettable/settable property named age of type Int Hint: To declare a property as gettable, add { get } after the type. For settable - { set } and combine both to get a gettable and settable property.
protocol UserType {
var name: String {get}
var age: Int {get set}
}
4 Answers
Jennifer Nordell
Treehouse TeacherJose is correct. The code should look like this with spaces and all.
protocol UserType {
var name: String { get }
var age: Int { get set }
}
Li Lin
Courses Plus Student 2,654 PointsIs it normal in XCode, or just special case here to add the spaces?
Jose Patarroyo
2,953 PointsI believe it's just in here, I tried the code in Xcode without spaces and it worked fine.
install
2,047 PointsI typed this into the challenge and it says "Bummer!" I'm going to try again, but I don't see the problem.
protocol UserType { var name: String { get } var age: Int { get set }
}
Dalisson Figueiredo
7,731 PointsThe problem is with treehouse only, don't worry, just add the spaces between get and the brackets like { get } and { get set } and it will work fine, in xcode it works without the spaces.
Jose Patarroyo
2,953 PointsJose Patarroyo
2,953 PointsIt needs to have a space before and after "get" and "set"