type SQLConn =
val mutable private connection : string option
member this.Connection
with get() : string = this.connection.Value
and set(v) = this.connection <- Some v
new (connection : string) = {connection = Some connection;}
new() = SQLConn @"Data Source=D:\Projects\AL\Service\ncFlow\dbase\dbflow.db3; Version=3;Password=432432434324"
I want to use “let x = 5+5” there or something like that, so how can I use private functions in my type (class) (record) , I know that I can use them if I do SQLConn() , but then I can’t use val, I want to use both : val and let …
thank you
As Tim explains, you can only use local
letbindings with the implicit constructor syntax. I would definitely follow this approach as it makes F# code more readable.Do you have any particular reason why you also want to use
valin your code? You can still use them with the implicit constructor syntax, but they have to be mutable and initialized using mutation:As far as I can tell
valis only needed to create fields that are not private (which may be required by some code-gen based tools like ASP.NET, but is otherwise not really useful).