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 trialTony Teixeira
14,823 PointsERROR: Expected member name or constructor call after type name
class Page {
let story = Story // Expected member name or constructor call after type name
typealias Choice = (title: String, page: Page)
var firstChoice: Choice?
var secondChoice: Choice?
init(story: Story) { // Cannot assign value of type 'Story' to type 'Story.Type'
self.story = story
}
}
Keep getting errors, is this a change in Swift or am I making an error?
1 Answer
Michael Hulet
47,913 PointsWhat I bet you're meaning to do on line 2 of your example is declare a constant called story
of type Story
, but your code is written using the assignment operator, which is not correct. In other words, I bet you meant to use a colon (:
) instead of an equals sign (=
). Try changing the second line to this and see what happens:
let story: Story
Tony Teixeira
14,823 PointsAhh absolutely what I was trying to do. I was wondering why it was not throwing an init error before I added the init method. Makes sense, my error... thanks!
Justin Janes
5,904 PointsJustin Janes
5,904 PointsI'm hitting this same problem two hours after you, I think it may be a gap between the video content and where Swift currently is.