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!
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

noahforbes
1,869 PointsFiguring out my func
I can't figure out why this won't work. I saw that someone asked a similar question, but the answer they got didn't quite make sense to me.
"Try instead of tag accessing the name property using tag.name"
Am I missing fundamentals heres or something silly.
struct Tag {
let name: String
}
struct Post {
var title: String
var author: String
var tag: Tag
func description() -> String {
return("\(title) by \(author). Filed under \(tag)")
}
}
let firstPost = Post(title: "ios", author: "Apple", tag: Tag(name: "whatevs"))
let postDescription = firstPost.description()
1 Answer

Heath R.
Courses Plus Student 1,211 Pointsstruct Tag { let name: String }
struct Post { let title: String let author: String let tag: Tag
func description() -> String {
return("\(title) by \(author). Filed under \(tag.name)")
}
}
let firstPost = Post(title: "Confidential", author: "Classified", tag: Tag(name: "MY52F7G98NB"))
let postDescription = firstPost.description()
tag is a struct and so you have to access its property by creating an instance of it in the description method, and not just write tag. This changes the firstPost as well, with the parentheses, and putting the tag name inside.
hope this helps!
noahforbes
1,869 Pointsnoahforbes
1,869 PointsYes. Thanks a bunch.