Background
A quick feedback on our last post.
Referenced Work
- PowerShell:- Datatype – Array – Declaration & Initialization
Link
Source Code Control
GitLab
PowerShell – Array – Declaration & Initialization – Sample – nameList
Link
Bug Report
Microsoft
PowerShell
An Uninitialized declared array leads to string concatenation #17313
Link
Feedback
Patrick Meinecke ( SeeminglyScience )
Image
Textual
So the latter isn’t actually declaring anything.
It’s just casting $nameListUnInitialized
(which will be null at that time) to string[]
.
Only the former actually creates a variable, so this behavior is by design.
Revised Code
Code
PowerShell – Array – Declaration & Initialization – Sample – nameList
Link
Output
Output – Image
Output – Textual
List - $nameListInitialized Type Name:- String[] BaseType:- System.Array 1) Joya 2) Tom 3) Kate Number of entries:- 3 List - $nameListUnInitialized Type Name:- String BaseType:- System.Object 1) JoyaTomKate Number of entries:- 1
Dedication
Crediting Patrick Meinecke.
Lifting up the favored and faithful.