swift - Using if let syntax in switch statement -


in swift if let syntax allows me execute statements if variable of type. example

class {...} class b: {...} class c: {...}  func foo(thing: a) {     if let b = thing as? b {         //     }else if let c = thing as? c {         // else     } } 

is possible achieve switch statement?

i have got far, variables b , c still of type a, not cast b , c:

func foo(thing: a) {     switch thing {     case let b b b:         //     case let c c c:         // else     default:         // else:     } } 

if want know whether it's b or c, can case b , case c.

if want capture , cast down, case let b b , case let c c.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -