-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Need additional documentation on how the instrinsic ForEach method wraps results in a collection #12879
Copy link
Copy link
Closed
Labels
area-aboutArea - About_ topicsArea - About_ topicsissue-doc-bugIssue - error in documentationIssue - error in documentation
Description
Prerequisites
- Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
- Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Typo in
Get-Foocmdlet" instead of "Typo." - Verify Version: If there is a mismatch between documentation and the behavior on your system, ensure that the version you are using is the same as the documentation. Check this box if they match or the issue you are reporting is not version specific.
Links
Summary
There is no information on the .ForEach(string propertyName) form that discusses how PowerShell handles properties that are collections. This issue has been raised in the PowerShell repo and the Engine-WG looked at this and concluded we need more documentation for the semantics of .ForEach(propName)
Details
Note how .ForEach() wraps both the scalar property and the array property within a collection such that accessing the first element of the original collection requires two indices [0][0]. The first index is for the wrapper collection that PowerShell creates, and then the second index is for the first element in the array returned by the referenced property name.
Suggested Fix
Update the topic to cover these semantics of ForEach(string propertyName).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-aboutArea - About_ topicsArea - About_ topicsissue-doc-bugIssue - error in documentationIssue - error in documentation