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 trialMonika Kesarwani
5,851 Pointsstructure i dont know where I m doing mistake in making instance of structure
struct Tag { let name: String }
struct Post{ var title: String var author: String var tag = Tag() }
let firstPost = Post(title: "Dove", author: "Monika", tag: Tag(name: "MyTag"))
struct Tag {
let name: String
}
struct Post{
var title: String
var author: String
var tag = Tag()
}
let firstPost = Post(title: "Dove", author: "Monika", tag: Tag(name: "MyTag"))
1 Answer
Steven Parker
231,236 PointsIn the defintion of "Post", you only need to define the argument "tag" by the type instead of creating an instance and performing an assignment:
var tag: Tag
Happy coding! And for some holiday-season fun and extra practice, give Advent of Code a try!
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherWoops! I composed an answer but will remove it as you've gotten a very solid one from Steven Parker! And he's correct, the Advent of Code is awesome