Reputation: 6940
In my class i want to check my model class using guard feature. I try to do following;
func bindWithModel(model: Any)-> Void {
guard let model is VacanciesItem else {
}
}
However, it throw me an error - Variable binding in a condition requires an initializer
How to fix it?
Upvotes: 1
Views: 375
Reputation: 390
You don't need the let keyword:
guard model is VacanciesItem else
Upvotes: 2
Reputation: 50099
let x = x
would be an assignment. you dont have any assignment though as you only test with is
.
so guard model is VanaciesItem
guard let model as? VanaciesItem
(I think that what you want most often)
Upvotes: 3