$a = @()
How do I check if $a above is empty (which it is). I would like to get $true as answer.
A PowerShell hash table is data structure of key/value pairs. A key/value pair is essentially a set of two elements that are related in some manner. In its simplest form, a hash table is just a way to store one or more sets of item names and item values.
That's not an associative array, it's a regular array, but the answer is the same. Use .Count and compare to 0.
An associative array is called a [hashtable] in PowerShell and its literal form uses @{} (curly braces).
@{}.Count -eq 0 # hashtable (associative array)
@().Count -eq 0 # array
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With