I have a type mapping a class in f# as follows:
type MyClass =
val myval: integer
new () = {
myval = 0;
}
member self.MyVal with
get () = self.myval
Well, I want to create an instance of this class.
I can do so:
let myinstance = MyClass ()
or
let myinstance = new MyClass ()
What’s the difference?
Can I do both?
For types which implements IDisposable should be instantiated using new. Otherwise you will get the following compilation warning.
It is recommended that objects that support the IDisposable interface are created using ‘new Type(args)’ rather than ‘Type(args)’ to indicate that resources may be owned by the generated value