import Foundation // Write your code here... func varProcessor(_ n: Any) { let nInt = n as? Int ?? 0 // 如果n是整形数,nInt将会被赋予n的值 let nString = n as? String ?? "" // 如果n是字符串,nString将会被赋予n的值 switch n { case is Int: // 如果n是整形,这里的代码将会被执行 // Write your code here... case is String: // 如果n是字符串,这里的代码将会被执行 // Write your code here... default: print("An error occurred.") } } // 测试用,不需要改动 let test: [Any] = [0, 2, 0.2, "Hello"] for item in test { varProcessor(item) }