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 trialBatuhan Dogan
2,587 Pointshelp me with this bummer!!
where am I doing wrong?
protocol User { var name: String { get } var age: Int { get set } }
struct Person{ var name: String var age: Int self somePerson = Person }
let Person = somePerson(name: "Batuhan", age: 19)
protocol User {
var name: String { get }
var age: Int { get set }
}
struct Person{
var name: String
var age: Int
self somePerson = Person
}
let Person = somePerson(name: "Batuhan", age: 19)
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! First, the self somePerson = Person
is not needed and you can safely remove that line. Secondly you have a struct named Person which currently conforms to no protocols but should conform to the User
protocol. To make something conform to a protocol we use a semicolon and then the name of the of the protocol. Like so struct myStruct : myProtocol
. That would be a struct named myStruct
which conforms to myProtocol
. On the final line you are supposed to declare a constant named somePerson
and assign it a new instance of Person
. However, you've declared a constant named Person
and tried to assign it a new instance of something called somePerson
. You've simply gotten this line a bit backwards.
I feel like you can get it with these hints, but let me know if you're still stuck!
Batuhan Dogan
2,587 PointsBatuhan Dogan
2,587 Pointsstill can't do it:(
protocol User { var name: String { get } var age: Int { get set } }
struct secondStruct : Person { var name: String var age: Int let somePerson = Person }
let somePerson = Person(name: "Batuhan", age: 19)
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherBatuhan Dogan Not quite! Now you've changed the name of the struct to
secondStruct
and made it conform to thePerson
protocol, which doesn't exist.We're looking for something like:
After we write the name of the struct we then write a colon and the name of the protocol it should conform to:
struct Person: User
. This is aPerson
that conforms toUser
.Give it another shot!