How to create a new structure instance in F #?

I feel very stupid in this matter, but it is very difficult for me to find documentation about this.

If I declare a structure like this:

type BuildNumber = struct val major : int val minor : int val build : int val revision : int end 

Then how to create a new instance of type BuildNumber ?

+6
source share
1 answer

You use the new keyword and define a constructor for it.

For instance:

 type simple = struct val A : int val B : int new (a: int, b: int) = { A = a; B = b; } end let s = new simple(1, 2) 
+3
source

Source: https://habr.com/ru/post/985224/


All Articles