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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Stuart Robertson](https://secure.gravatar.com/avatar/f78eb23d85bd68ce8ef10513ad938e21?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Stuart Robertson
Courses Plus Student 1,296 PointsProtocol Conformance Through Extensions
Hey! the error says: "Make sure you extend User and conform to PrettyPrintable"
What am I Doing Wrong! Typo?
protocol PrettyPrintable {
var prettyDescription: String { get }
}
struct User: PrettyPrintable {
let name: String
let ID: Int
var prettyDescription: String {
return "User name is \(name) and UserID is \(ID)"
}
}
// Enter your code below
1 Answer
![Tobias Helmrich](https://secure.gravatar.com/avatar/2c796664737186546139ab14e7600534?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Tobias Helmrich
31,602 PointsHey Stuart,
you were on the right track but in this case you want to add additional functionality to the existing User
struct by using an extension like you saw in the video before.
To do this you can use the extension
keyword in combination with the struct you want to add the functionality to followed by the protocol you want to conform to:
protocol PrettyPrintable {
var prettyDescription: String { get }
}
struct User {
let name: String
let ID: Int
}
// Enter your code below
extension User: PrettyPrintable {
var prettyDescription: String {
return "Name: \(name), ID: \(ID)"
}
}
I hope that helps, good luck! :)
Stuart Robertson
Courses Plus Student 1,296 PointsStuart Robertson
Courses Plus Student 1,296 PointsOh, that's very helpful. Thank You!! :)