Reputation: 325
I need to have class like the following
type BubbleChartSeriesDefaults()=
let mutable _type:string = ""
member t.type with get() = _type and set v = _type <- v
F# does not like me using the keyword type as a property name. I am sending some f# types down the http pipe to be consumed by a javascript client. The consumer is looking for a property name called type. Using a keyword for a property name is not great but, is there any way of sneaking round this. Anyone know how to get a property called type onto a f# class ? (Kind of like using @case for variable in c# ...)
Upvotes: 3
Views: 682
Reputation: 11525
In F#, you can use anything you want as an identifer (property name, type name, etc.) if you enclose it in double backticks. In your case:
type BubbleChartSeriesDefaults()=
let mutable _type:string = ""
member t.``type`` with get() = _type and set v = _type <- v
Upvotes: 6