This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
import Foundation
func varProcessor(_ n: Any, /* Write your code here */) {
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是字符串,这里的代码将会被执行
default:
print("An error occurred.")
}
let test: [Any] = [0, 2, 0.2, "Hello"]
for item in test {
varProcessor(item, /* Write your code here */)