Skip to content

Why is ,(1)[1] different from ,$null? #6357

Closed

Description

@alx9r

I'm trying to understand why the following two statements yield different outputs:

&{,$null} | % {'x'} # x
&{,(1)[1]} | % {'x'} # no output

,$null and ,(1)[1] both seem to be arrays containing a single null element. Yet they behave differently during output from a scriptblock. What is happening here?

Activity

  1. powercode commented on Mar 10, 2018

    @powercode
    Collaborator

    The second returns AutomationNull.Value which is not enumerated by the pipeline.

    $null is enumerated.

    See for example the implementation of foreach:

  2. alx9r commented on Mar 10, 2018

    @alx9r
    Author

    Thank you Staffan Gustafsson (@powercode). For other readers, here are some resources on AutomationNull:

  3. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Mar 24, 2018
  4. mklement0 commented on May 5, 2018

    @mklement0
    Contributor

    alx9r: This comes down to the question you later asked in #6436 and which I've brought into focus in #6436 (comment), but I've decided to create a separate issue for it: #6823

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions