Skip to content

Conversation

@yecril71pl
Copy link
Contributor

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

  • Overview and Install
  • Learning PowerShell
    • PowerShell 101
    • Deep dives
    • Sample scripts
    • Remoting
  • Release notes (What's New)
  • Windows PowerShell
    • WMF, ISE, release notes, etc.
  • DSC articles
  • Community resources
  • Gallery articles
  • Scripting and development
    • Language Spec
    • Legacy SDK

Cmdlet reference & about_ topics

  • Preview content
  • Version 7.1 content
  • Version 7.0 content
  • Version 5.1 content

PR Checklist

  • I have read the contributors guide and followed the style and process guidelines
  • PR has a meaningful title
  • PR is targeted at the staging branch
  • All relevant versions updated
  • Includes content related to issues and PRs - see Closing issues using keywords.
  • This PR is ready to merge and is not Work in Progress
    • If the PR is work in progress, please add the prefix WIP: or [WIP] to the beginning of the
      title and remove the prefix when the PR is ready.

@opbld33
Copy link

opbld33 commented Nov 1, 2021

Docs Build status updates of commit abc4053:

✅ Validation status: passed

File Status Preview URL Details
reference/7.2/Microsoft.PowerShell.Core/About/about_Operators.md ✅Succeeded View (powershell-7.2)

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:

Copy link
Collaborator

@sdwheeler sdwheeler left a 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.

Comment on lines +454 to +458
Given a list of indices, the operator returns a list of members corresponding to those indices.

```powershell
-JOIN '123'[ 2 .. 0 ] -EQ '321'
```
Copy link
Collaborator

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

Comment on lines +460 to +465
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
```
Copy link
Collaborator

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
True

Style note - all keywords and operators should be lowercase

@sdwheeler
Copy link
Collaborator

Closing this PR. Please add the necessary changes to #8280.

@sdwheeler sdwheeler closed this Nov 11, 2021
@yecril71pl yecril71pl deleted the patch-6 branch November 12, 2021 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants