From 5c79b4288c9c1de5db6e1eb3856191f9381f7d4f Mon Sep 17 00:00:00 2001 From: Andrew Ryan Davis Date: Sun, 16 Aug 2020 14:58:29 -0700 Subject: Adjusting array section to be more accurate The default array object is mutable, but is of a fixed length. Changing comments to better reflect that. --- powershell.html.markdown | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/powershell.html.markdown b/powershell.html.markdown index 45c47017..7c54dc44 100644 --- a/powershell.html.markdown +++ b/powershell.html.markdown @@ -183,11 +183,12 @@ $someVariable # => 5 # Ternary Operators exist in Powershell 7 and up 0 ? 'yes' : 'no' # => no -# The default array object in Powershell is an immutable array +# The default array object in Powershell is an fixed length array $defaultArray = "thing","thing2","thing3" -# you are unable to add or remove objects +# you can add objects with '+=', but cannot remove objects $defaultArray.Add("thing4") # => Exception "Collection was of a fixed size." -# To have a mutable array, you will need to use the .NET ArrayList class +# To have a more workable array, you'll want the .NET [ArrayList] class +# It is also worth noting that ArrayLists are significantly faster # ArrayLists store sequences [System.Collections.ArrayList]$array = @() -- cgit v1.2.3