我如何拥有价值观,例如在代码余额中保留5英镑,以便程序运行
type Account =
{accountNumber:string; mutable balance:float}
member this.Withdraw(cash:float) =
if cash > this.balance then
Console.WriteLine("Insufficient Funds. The Amount you wish to withdraw is greater than your current account balance.")
else
this.balance <- this.balance - cash
Console.WriteLine("You have withdrawn £" + cash.ToString() + ". Your balance is now: £" + this.balance.ToString())
member this.Deposit(cash:float) =
this.balance <- this.balance + cash
Console.WriteLine("£" + cash.ToString() + " Cash Deposited. Your new Balance is: £" + this.balance.ToString())
member this.Print() =
Console.WriteLine("Account Number: " + this.accountNumber)
Console.WriteLine("Balance: £" + this.balance.ToString())
警告FS0988:程序主模块为空:运行时将不会发生任何事情
我试图输入以下代码:
let accountNumber = 123
let balance = 5
但仍然没有任何反应