Legal in Swift, the Silver compiler emits:
(E62) Type mismatch, cannot assign “PersonProtocol!” to “ordinal type” for the switch
statement in the code below:
protocol PersonProtocol {
var profession: String {get}
}
class SwiftProgrammer:PersonProtocol {
let iq="over 130"
let profession = "Swift Programmer"
}
struct FootballPlayer:PersonProtocol {
let height="over 72 inches"
let profession = "Football Player"
}
var sp1=SwiftProgrammer(), fp1=FootballPlayer(), pp:PersonProtocol=sp1
switch(pp) {
case is SwiftProgrammer: print("nerd")
case is FootballPlayer: print("jock")
default: print("shrug")
}