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 trialDavid Gourley
3,818 PointsCalling Instances with custom data types
Hi guys I'm having difficulties with this current task, I feel like everything is ok but I'm probably missing some simple syntax.
I keep getting the error message:
swift_lint.swift:19:50: error: cannot convert value of type 'Tag.Type' to expected argument type 'Tag'
let firstPost = Post(title: "", author: "", tag: Tag)
any help would be appreciated.
struct Tag {
let name: String
}
struct Post {
let title: String
let author: String
let tag: Tag
}
let firstPost = Post(title: "", author: "", tag: Tag)
1 Answer
Sam Belcher
3,719 PointsHi, your code looks good except the last part where you are assigning a value to "tag". Since you want to give "tag" a value of "Tag", you have to give an instance for the stuct "Tag" as well. Hope that helped. My code that passed the challenge is below:
struct Tag {
let name: String
}
struct Post {
let title: String
let author: String
let tag: Tag
}
let firstPost = Post(title: "", author: "", tag: Tag(name: ""))