The F# structure is a data structure which is used to organize data, and it is value types and efficient than class. It does not allow let binding, so you must declare fields by using val keyword.
Below is an example of inline function in F# programming language:
1 2 3 4 5 6 7 8 9 10 11 | type Book = struct val title : string val author: string val price : float new (title, author, price) = // Constructor {title = title; author = author; price = price;} end let book = new Book("FSharp Programming", "Chris Smith", 100.0) // Calling Constructor printfn "Title : %s " book.title printfn "Author : %s" book.author printfn "Price : $%0.2f" book.price |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.