David S.
David S.

Reputation: 11168

How to define a F# abstract member with empty type-signature

According to this page, all abstract members of a class must have a type-signature. But I want to define a abstract class that has void input parameter and void return type. And void is not valid keyword in this context.

Upvotes: 2

Views: 654

Answers (1)

kvb
kvb

Reputation: 55184

In F#, you typically use the unit type where you would use the void keyword in C#. So an example of what you're looking for would be:

[<AbstractClass>]
type MyAbstractClass() =
    abstract MyMethod : unit -> unit

type MyDerivedClass() =
    inherit MyAbstractClass()
    override this.MyMethod() = printf "Do something here..."

Upvotes: 5

Related Questions