-
Notifications
You must be signed in to change notification settings - Fork 1.7k
op[]: mention lists of indices and non-collections #8282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Docs Build status updates of commit abc4053: ✅ Validation status: passed
For more details, please refer to the build report. Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report. For any questions, please:
|
sdwheeler
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the submission. I have several pieces of feedback for you. See my comments below.
Also, when submitting changes to a file, the changes need to be made to all versions of the file. You have submitted two PRs for the same file (about_Operators). Please combine the changes in one PR. Include all versions of the changed file in the PR.
If you want to wait for feedback before copying the changes to the other versions, mark the PR as a Work-in-Progress [WIP] as described in the PR template. After the feedback you can make the necessary changes to all version and update the PR.
| Given a list of indices, the operator returns a list of members corresponding to those indices. | ||
|
|
||
| ```powershell | ||
| -JOIN '123'[ 2 .. 0 ] -EQ '321' | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. is the range operator so it is better described as: "Give a range of indices...".
The example is overly complicated. It is better to just show the output. For example:
PS> '123'[2..0]
3
2
1
| If an object is not an indexed collection, its first element is the object itself. Index lists are not supported. | ||
|
|
||
| ```powershell | ||
| (0)[0] -EQ 0 | ||
| (0)[0,0] -EQ $NULL | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an object is not an indexed collection, accessing first element returns the object itself. Index values beyond the first element return $null.
All of those zeros can be confusing. I suggest the following
PS> (2)[0] -eq 2
True
PS> (2)[-1] -eq 2
True
PS> (2)[1] -eq $null
True
PS> (2)[0,0] -eq $null
TrueStyle note - all keywords and operators should be lowercase
|
Closing this PR. Please add the necessary changes to #8280. |
PR Summary
Add missing information about the behaviour of
operator[]with lists of indices and with non-collections.PR Context
Select the area of the Table of Contents containing the documents being changed.
Conceptual content
Cmdlet reference & about_ topics
PR Checklist
WIP:or[WIP]to the beginning of thetitle and remove the prefix when the PR is ready.