I need to create a mutable option<T>
type in F#. I've tried writing
let x = ref None
and subsequently writing
x := Some(z)
but it doesn't work. Help!
You need to state the type explicitly to avoid "the Value Restriction" (or see "Automatic Generalization" on msdn):
let x : Ref<int option> = ref None
x := Some 4
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