What is the best way in F# to write an if not condition?
Right now I'm writing it like this:
if condition <> true then do
Is there any other shorter way to write it? Like using the ! operator?
if you consider that not is also a function, then you can pipe your condition into it to avoid parenthesis like so:
if not <| condition param1 param2 then ...
reason being is if your condition function takes arguments, you don't need to do
not (condition param1 param2)
it's probably a little cleaner to do it the first way since it seems f# is in favor of pipes instead of parenthesis for operator precedence.
In Ocaml, you can use the "not" keyword:
if not condition then ...
Hopefully works too with F#.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With