Hi Folks
I have noticed some strange behavior around this situation… if I write a simple function to pluck an optional field from a record, the types dont line up: I expect the result of the plucked function to be option
Thanks,
A
Hi Folks
I have noticed some strange behavior around this situation… if I write a simple function to pluck an optional field from a record, the types dont line up: I expect the result of the plucked function to be option
Thanks,
A
You can use question mark to get the optional value. But I agree, I was also confused by the behaviour.
What’s happening in this case is that you basically only take into account the case where thing is not None, you don’t have an exhaustive pattern match and the compiler warns you about it.
breaking equivalence betweeen {thing}
and t.thing
is a burden still. IMO. I can work through the exception, but it gives a bad experience.
It can be confusing the first time, but the alternative has bigger issues.