Add exists to suite of traversal functions and methods to check if path exists #8
Labels
No labels
bug
duplicate
enhancement/documentation
enhancement/feature
enhancement/organization
question
rejected
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
UserCurt/mpath#8
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
It can be useful to check whether a given field exists in a struct. The proposed method/function is analogous to MATLAB's
isfieldandexistfunctions. There would be ampath.existfunction and anmpath.Pointer.existmethod. The function/method will return a logical depending on whether the field exists or not.Alternatively, if
mpath.ConcretePointeris to be implemented as described in #6, it could contain a property for whether the path exists or not. Then one could have a few options:Since this issue was created, some things have changed.
Name changes:
mpath.exists(data, path, ...)path.exists(data, ...)Other changes:
NullFieldwas replaced byMissingPolicyandNonmissingRequirementFillGapswas replaced byMissingPolicy="missing"andSizeMismatchPolicy="fill"ConcretePointerwas not introduced. Concrete, missing, and unreached state is now tracked as internal traversal metadataImplemented in
e91fdb8.