Reputation: 1284
I have this code which isn't working
type Option(xsdLocation:string, xmlDirectory:string) =
member this.XsdLocation = xsdLocation
member this.XmlDirectory = xmlDirectory
let a1 = new Option("xsd","xml")
let a2 = {a1 with XsdLocation = "xsd2"}
i get the error
error FS1129: The type 'Option' does not contain a field 'XsdLocation'
Upvotes: 1
Views: 51
Reputation: 12184
The object you defined is a standard .NET class, not a record. If you want to use with
syntax you should define it as such:
type Option = {XsdLocation : string; XmlDirectory : string}
let a1 = {XsdLocation = "xsd"; XmlDirectory = "xml"}
let a2 = {a1 with XsdLocation = "xsd2"}
PS: I'd also recommend picking a name other than Option
for your type since Option
is a built-in type.
Upvotes: 4