1
在下面的代码中,我想弄清楚为什么最后2行显示为错误。不能将类型'字符串'的值转换为期望的参数类型'(名称:字符串,余额:双)'
var account1 = ("State bank personal, 1011.10")
var account2 = ("State bank business, 24309.63")
func deposit(amount : Double, account : (name : String, balance : Double)) -> (String, Double) {
let newBalance : Double = account.balance + amount
return (account.name, newBalance)
}
func withdraw(amount : Double, account : (name : String, balance : Double)) -> (String, Double) {
let newBalance : Double = account.balance - amount
return (account.name, newBalance)
}
var mondayTransaction = deposit
var fridayTransaction = withdraw
let mondayBalance = mondayTransaction(300.0, account1)
let fridayBalace = fridayTransaction(1200.0, account2)