I have this code to raise an error when file doesn't exist.
if !File.Exists(doFile) then
    printfn "doFile doesn't exist %s" doFile; failwith "quit"
However, I got this error. What's wrong?
error FS0001: This expression was expected to have type
    bool ref    
but开发者_运维问答 here has type
    bool
The ! operator has a special meaning in F#, its defined as:
type 'a ref { Contents : 'a }
let (!) (x : ref 'a) = x.Contents
You're getting the error because the ! operator expects a bool ref, but you passed it a bool.
Use the not function instead:
if not(File.Exists(doFile)) then
    printfn "doFile doesn't exist %s" doFile; failwith "quit"
in F# ! is not a NOT, it's a referencing operatior, so to say not, you need to use the not function, something like if not <| File.Exists....
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论