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 trialJack Baer
5,049 PointsSwift Recap Part 1 (Build a Simple iPhone App Course)
I've been stumped on this challenge, since the error I'm getting has no explanation (It just says "Bummer," and there is nothing in the preview tab).
I also tried adding an init method to try and fix it, but nothing worked.
I would appreciate any help. Thanks!
struct 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)"
}
}
let firstPost = Post(title: "Book", author: "Writer", name: Tag(name: "Swift"))
let postDescription = firstPost.description
3 Answers
Jeff McDivitt
23,970 PointsHi Jack -
The task's treehouse are very picky, your code will work, but look at my method you need to use tag.name
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.name)"
}
}
let firstPost = Post(title: "The Task", author: "Me", tag: Tag(name: "Swift"))
let postDescription = firstPost.description()
Jeff McDivitt
23,970 PointsNo problem, it is because of the way the structure is set -up that you need to use the dot notation
Didi Medina
5,468 PointsI literally got stuck on this challenge for an hour bec I had a period after \(tag.name)
. Very picky.
Jack Baer
5,049 PointsJack Baer
5,049 PointsThanks a bunch! Didn't realize you needed to use dot notation for the method.