I'm wondering about the two syntax for the getters:
type Direction =
| Undefined
| Buy
| Sell
member this.Symbol =
match this with
| Direction.Buy -> '↑'
| Direction.Sell -> '↓'
| Direction.Undefined -> '→'
member this.Symbol2 with get() =
match this with
| Direction.Buy -> '↑'
| Direction.Sell -> '↓'
| Direction.Undefined -> '→'
Is there any practical difference between the first one and the second one? The IL looks identical, but from the usage standpoint? is one preferred for any reason?
They are identical, yes. In general, prefer the first one. The reason why the second one exists is if you have some special logic to do that isn't just grabbing a value. It's more flexible, but more syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With