小编Sam*_*rry的帖子

F#If语句期望浮点数的单位

该语句是正确的,直到最后一个省略号,然后出现错误“预期具有类型单位”

type BankAcc = {AccNum:int; mutable  Balance:float} with

    member this.Withdraw(amount,?withdrawal) =
     let withdrawAmount = this.Balance * float amount
     match withdrawal with
      | None -> withdrawAmount
      | Some deduct -> withdrawAmount - deduct
let Account ={AccNum=123;Balance = 15.00}

Account.Withdraw(25.00) // withdrawing 25 from an account with a balance of 15

let test Balance withdrawAmount =
  if Balance = withdrawAmount then "Equals"
  elif Balance < withdrawAmount then "Balance too low"
  else Balance - withdrawAmount 

  Account={AccNum =0001; Balance=0.00};   

let CheckAccount Balance = 
    if …
Run Code Online (Sandbox Code Playgroud)

f# if-statement

2
推荐指数
1
解决办法
53
查看次数

标签 统计

f# ×1

if-statement ×1