Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create empty class in F#

Tags:

f#

I know this is stupid question. I can create an empty class like the following in c#.

class Customer{}

But How can I do this in F#? This is my try

type Customer() =

   let _ = ()

What is the correct way?

like image 420
Fred Yang Avatar asked Jul 12 '11 17:07

Fred Yang


People also ask

How do you declare an empty class?

In Python, to write an empty class pass statement is used. pass is a special statement in Python that does nothing. It only works as a dummy statement. However, objects of an empty class can also be created.

Can we create empty class?

C++ allows creating an Empty class, yes! We can declare an empty class and its object. The declaration of Empty class and its object are same as normal class and object declaration.

Can we create empty class in Java?

"Can I have an empty Java class?" - Yes.

Can a class be empty in C#?

There will be no option to create an empty C# class.


1 Answers

Try

type Customer() = class end

Normally, you can leave the class and end tokens implicit and the compiler infers their presence at the beginning and end of the class's definition, but if the class is completely empty you'll need to specify them. Likewise, you can use struct end and interface end to generate structs and interfaces.

like image 199
kvb Avatar answered Oct 21 '22 09:10

kvb