Page 202

Swift

println("Instance equation is: \(samplechem.equations)")

let samplemaths = Maths(physics: "Fluid Dynamics", formulae: "Giga Hertz") println("Instance physics is: \(samplemaths.physics)") println("Instance formulae is: \(samplemaths.formulae)")

var chemCount = 0 var mathsCount = 0

for item in saprint { if let print = item as? Chemistry { println("Chemistry topics are: '\(print.physics)', \(print.equations)") } else if let example = item as? Maths { println("Maths topics are: '\(example.physics)',

\(example.formulae)")

} }

var exampleany = [Any]() exampleany.append(12) exampleany.append(3.14159) exampleany.append("Example for Any") exampleany.append(Chemistry(physics: "solid physics", equations: "Hertz"))

for print in exampleany { switch print { case let someInt as Int: println("Integer value is \(someInt)") case let someDouble as Double where someDouble > 0: println("Pi value is \(someDouble)") case let someString as String: println("\(someString)") case let phy as Chemistry: println("Topics '\(phy.physics)', \(phy.equations)") default: 190

​Quick is just a powerful and spontaneous programming language for macOS, iOS, watchOS and tvO...  

...

Advertisement