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 trialNils Sens
9,654 PointsNo preview errors but not passing....
can anyone see what I missed here? ty :)
struct Tag {
let name: String
}
struct Post {
let title: String
let author: String
let tag: Tag
func description() -> String {
return "\(self.title) by \(self.author). Filed under \(self.tag)"
}
}
let firstPost = Post(title: "iOS Development", author: "Apple", tag: Tag(name: "swift"))
let postDescription = firstPost.description()
3 Answers
Maria Angelica Dadalt
6,197 PointsYour function's return is incorrect. You usually use self to initialize properties, not in functions or methods. You only need to put the name of the property.
Here's how it should be.
return "\(title) by \(author). Filed under \(tag.name)"
Maria Angelica Dadalt
6,197 PointsTotally weird. Didn't know that it passed with the self notation! The code must be all perfect and match the answer almost exactly to pass through. That sucks sometimes, because Xcode says all is ok, but Teamtree doesn't accept the code.
Dhanish Gajjar
20,185 PointsNils Sens Maria Angelica Dadalt It is true, the treehouse code editor is very strict in terms of the accepting the answers.
Nils Sens
9,654 PointsNils Sens
9,654 PointsAh, I tried that before, should've said that. same result.... OH! "tag.name" the period there! waaah!! :))
Thank you again, you're kinda awesome!
EDIT: The 'self' there actually passes, but I know what you mean. ;) (funny how this code ch. was already marked as completed by the sys though...)