Skip to content
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

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

Closed
alx9r opened this issue Mar 10, 2018 · 3 comments
Closed

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

alx9r opened this issue Mar 10, 2018 · 3 comments
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Answered The question is answered.

Comments

@alx9r
Copy link

alx9r commented Mar 10, 2018

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?

@powercode
Copy link
Collaborator

powercode commented Mar 10, 2018

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

$null is enumerated.

See for example the implementation of foreach:

@alx9r
Copy link
Author

alx9r commented Mar 10, 2018

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

@alx9r alx9r closed this as completed Mar 10, 2018
@iSazonov iSazonov added Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Answered The question is answered. labels Mar 24, 2018
@mklement0
Copy link
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
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Answered The question is answered.
Projects
None yet
Development

No branches or pull requests

4 participants