Need a little help with this

// 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’

nvm…got it working

Hi @lac_ekim,
I guess you found the typo, useChopstics instead of useChopstick

cheers,

Jayant

1 Like

This topic was automatically closed after 166 days. New replies are no longer allowed.