Is there any way to make a property that is defined in a class compulsory?
I want the compiler to complain if the object is declared and used without the compulsory property.
Is there any way to make a property that is defined in a class
Share
A way might be to implement a constructor that forces the creation of an object to have an initial value for a property:
Now the client can only create the object by passing a value for p: