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 trialEddie Aguilar
2,393 PointsCompiles fine in Xcode but will not pass in Treehouse, can someone explain what is wrong here??
Description says it all.
struct Tag {
let name: String
}
struct Post{
var title: String
var author: String
let tag = Tag(name: "Swift")
func description () -> String{
let all = "\(title) by \(author). Filed Under \(tag.name)"
return all
}
}
let firstPost = Post(title: "IOS Developer", author: "Apple")
let postDescription = firstPost.description()
1 Answer
Brandon Mahoney
iOS Development with Swift Techdegree Graduate 30,149 PointsYou have a few spelling errors and a code error. Also you didn't need the extra constant in the method. I will let you do the comparison here. Make sure to check the spelling of the Strings.
struct Tag {
let name: String
}
struct Post{
var title: String
var author: String
let tag: Tag
func description() -> String {
return "\(title) by \(author). Filed under \(tag.name)"
}
}
let firstPost = Post(title: "iOS Developer", author: "Apple", tag: Tag(name: "Swift"))
let postDescription = firstPost.description()