I'm working through Big Nerd Ranch's Swift Programming book (2nd edition), and in the chapter on the Switch statement, there's a small section on in-cases and how to use them. When describing how to implement if-cases with multiple conditions, this is the code the book shows:
...
let age = 25
if case 18...35 = age, age >= 21 {
print("In cool demographic and of drinking age")
}
When I try implementing this (exactly as it is) in my Xcode playground, however, I get an error ("variable binding in a condition requires an initializer")
It seems that the age >= 21 bit is the actual problem, as this
let age = 25
if case 18...35 = age{
// Same thing
}
works fine. What am I doing wrong in the multiple-condition code?