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 trialBob Clanfield
2,372 PointsI can't tell if this is bad code or SwifLlint issues. Any insights?
Been on a trip around the universe, trying to get this code to work and keep coming back to this syntax, thinking it's correct because Xcode compiles. Is it bad code or perhaps a SwiftLint issue?
protocol User {
var name: String { get }
var age: Int { get set }
}
struct Person: User {
var name: String
var age: Int
}
let somePerson = Person(name: "X", age: 0)
7 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHi Bob,
Jeff McDivitt is correct in that your code just has a spacing error. The problem is on this line:
let somePerson = Person(name: "X", age: 0)
If you look, the variable somePerson
is grey instead of blue. This is because there is an extra space after the let
keyword. Once you delete a space, you code passes too.
Just an FYI for you guys, in case you were wondering why.
Keep Coding!
Jeff McDivitt
23,970 PointsHi Bob -
Your code is correct, if it is not letting you pass the challenge try refreshing your browser and also clearing the cache
protocol User {
var name: String { get }
var age: Int { get set }
}
struct Person: User {
var name: String
var age: Int
}
let somePerson = Person(name: "Jeff", age: 35)
Bob Clanfield
2,372 PointsHi Jeff, Thank you for responding. I've tried reloading and shutting down Safari. I even tried signing in with an Opera browser. The result is always comes back as ⓧ Bummer!
Jeff McDivitt
23,970 PointsJust for the heck of it, try pasting in my code
Bob Clanfield
2,372 PointsYour code passed the challenge
Jeff McDivitt
23,970 PointsProbably just some spacing or something; sometimes the treehouse code editor can be a pain
Bob Clanfield
2,372 PointsThat was the best case scenario Many Thanks ¯_(ツ)_/¯ ॐ
Mohammad Arna'uti
Courses Plus Student 2,743 PointsWhen I need to use getter and setter ?
Jeff McDivitt
23,970 PointsJeff McDivitt
23,970 PointsAwesome Jason! Thanks