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 trialReza Shirazian
5,337 Pointscode works fine, editor says it could not be compiled but provides no output
code works fine, editor says it could not be compiled but provides no output
struct Tag {
let name: String
}
struct Post {
let title: String
let author: String
let tag: Tag
}
let firstPost: Post
2 Answers
Michael Drexler
4,374 PointsHy Reza Shirazian,
you are declaring a constant with the name "firstPost" but you donΒ΄t assign a value to this constant. Have you already tried to assign a value/instance to this constant?
Michael Drexler
4,374 PointsThe instructions say the following: "Create an instance of Post and assign it to a constant named firstPost."
That means you have to create an object of the type Post and assign it to the constant. Because a struct provides a default initializer method you can just simple create an object like the following code shows.
let firstPost: Post = Post(title: "AnyTitle", author: "AnyAuthor", tag: Tag(name: "AnyName"))
Reza Shirazian
5,337 PointsReza Shirazian
5,337 PointsYea I figured it out. The instructions didn't say we should assign values to it.