I’m just curious, these two functions would do the same thing. But which one should I use?
let f a =
match a with
b -> a;;
let f a =
match a with
b -> b;;
Or it just depends on your preference?
I feel the second one would be better but I’m not sure.
Performance wise there is no difference. Style-wise
b -> ais a bit problematic because you have an unused variableb._ -> awould make more sense. Other than that, it’s just preference.Personally I would prefer
_ -> aoverb -> bbecause it doesn’t introduce an extra variable.PS: I assume in your real code there are more cases than just
b– otherwise you could just writelet f a = a.