I added this failable initializer in my Monster class, but no errors appeared when I built it pointing to my Zombie subclass, which the challenge suggests I’d need to adjust:
You should have gotten an error in Zombie’s designated initializer because the super.init call generates an optional but Zombie’s initializer doesn’t return an optional. I’m not sure why you didn’t see that error.
Also, your code here doesn’t do what the challenge is asking, it still allows monsterName to be set to an empty String ("").
(Sorry I didn’t see this last September, I was traveling at the time. I’m just now getting around to that chapter.)
required init!(town: Town?, monsterName: String)
{
self.town = town
name = monsterName
if(name == “”)
{
return nil
}
}
For Zombie class
It’s designated init
init!(limp: Bool, fallingApart: Bool, town: Town?, monsterName: String)
{
walksWithLimp = limp
isFallingApart = fallingApart
super.init(town: town, monsterName: monsterName)
}
Note: used the unwrapped optional (!) because I have other initializers on the Zombie class that need to delegate to that initializer. (can delegate from init to init!).