private func vvodAge() ->Int{
var vvod:String? = readLine()
if ((vvod == nil)){vvod = "0"}
return Int(vvod)
}
//我只需要输入一个字符串检查它并输出int
试试下面的
func vvodAge() -> Int {
var vvod:String? = readLine()
if ((vvod == nil)){vvod = "0"}
return Int(vvod!)!
}
print(vvodAge())
然后像这样输入命令
#swiftc foo.swift
#echo "100" | ./foo // => 100