小编Jac*_*cob的帖子

F#小于模式匹配中的运算符

由于某种原因,此模式匹配中的小于运算符将不起作用.这是我唯一的错误,它让我疯狂.我可能错过了一些非常明显的东西,但感谢所有的帮助.

let CheckAccount account = 
match account with
| {Balance < 10.00} -> Console.WriteLine("Balance is Low")
| {Balance >= 10.00 and <= 100.00} -> Console.WriteLine("Balance is OK")
| {Balance > 100.00} -> Console.WriteLine("Balance is High")
Run Code Online (Sandbox Code Playgroud)

这是类型:

type Account = {AccountNumber:string 
            mutable Balance:float} 
            member this.Withdraw(amnt:float) = 
                if amnt > this.Balance then
                    Console.WriteLine("Unable to withdraw. The Amount you wish to withdraw is greater than your current balance.")
                else
                    this.Balance <- this.Balance - amnt
                    Console.WriteLine("You have withdrawn £" + amnt.ToString() + ". Your …
Run Code Online (Sandbox Code Playgroud)

f# pattern-matching

3
推荐指数
1
解决办法
1734
查看次数

标签 统计

f# ×1

pattern-matching ×1