Consider the interface:
type IVector =
abstract Item : int -> float
Now, let us define the class:
type DenseVector(size : int) =
let mutable data = Array.zeroCreate size
interface IVector with
member this.Item with get n = data.[n]
What about supply a method to mutate the n-th entry of the dense vector? Then, it would be nice to modify the above code as:
type DenseVector(size : int) =
let mutable data = Array.zeroCreate size
interface IVector with
member this.Item with get n = data.[n]
and set n value = data.[n] <- value
However, I get the following error because of the signature of the abstract method Item
in the IVector
interface:
No abstract property was found that corresponds to this override.
So, what should be the signature of Item
in IVector
?
type IVector =
abstract Item : int -> float with get, set
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