1

Take the following snippet

'a',$null,'b'

This is the result

a
b

Is there a way to change this default? So that null is actually treated in output as something.

2 Answers 2

2

There's no way to change that behaviour, but as a workaround you can do this:

[string[]]('a',$null,'b')

to get the desired result.

Sign up to request clarification or add additional context in comments.

Comments

1

This will turn the $null into a blank string:

'a',$null,'b' | % { "$_" }

Or you could transform the $null into some arbitrary string such as '[null]':

'a',$null,'b' | % { if ($_ -ne $null) {$_} else {'[null]'} }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.