// Problem: no more type casting
let random: Any = [1, “String”, [“123”]]
//: Design Protocol
protocol EastAsianable {
var useChopstick: Bool { get }
var origin: String { get }
}
extension EastAsianable {
var useChopstics: Bool {
return true
}
}
//: Create Blue Print
struct Korean: EastAsianable {
var origin: String = “Korea”
}
class Japanese: EastAsianable {
var origin: String = “Japan”
}
struct Chinese: EastAsianable {
var origin: String = “China”
}
let eastAsians: [EastAsianable] = [Korean(), Japanese(), Chinese()]
issues: Type ‘Korean’ does not conform to protocol ‘EastAsianable’, Type ‘Japanese’ does not conform to protocol ‘EastAsianable’, Type ‘Chinese’ does not conform to protocol ‘EastAsianable’