Reputation: 10482
How do I declare that I want something of type 'a
which I have no value for yet.
type MyType<'a> =
let mutable something:'a = ??
let setSomething item:'a =
something <- a
Upvotes: 1
Views: 136
Reputation: 13577
You can use Unchecked.defaultof<'a>
. That said, a nicer way for me would be to make something
an Option of 'a. That way the intention of ”not having a value“ would be made clearer.
type MyType<'a> =
let mutable something:'a option = None
let setSomething (item:'a) =
something <- Some a
Upvotes: 6