Closed yajan-singh closed 1 year ago
Reason
is a string under the hood. Compared to integers and floats, empty strings aren't valid enum values and this allows to use a value type instead of a pointer type for achieving the same "optional" behavior.
When using the library and checking whether this field is set, it makes no difference whether you do:
if req.Transaction.StoppedReason != nil
if req.Transaction.StoppedReason != ""
However, having enum fields as value types has the following advantages:
The entire library is built on this foundation and changing it would mean changing many other enum fields across the codebase (see ChargingState
in the same struct for example). I honestly don't plan on changing every single enum field to a pointer, unless this gets heavily upvoted and there is a good motivation.
Closing due to inactivity.