let myCar = "Ford Focus"
let yourCar = "Ford Fiesta"
switch car {
case “BMW” :
let myComment = “Need more cash”
case let x where
x.hasSuffix(“Ford”) // put the content into temp variable "x" and compare
let myComment = “your car now is \(x) ? “
// interpret the var x inside the bracket with slashes
default:
myComment
= “Any car will do for me as long as it is cheap”
}
No comments:
Post a Comment