Comparison of programming languages (associative array): Difference between revisions

Content deleted Content added
brush up
Jsnover (talk | contribs)
Updated PowerShell entry
Line 932:
$myOtherObject = @{ foo = 42; bar = $false }
</source>
 
Entries can be seperated by either a semicolon or a newline, e.g.:
 
<source lang="text">
$myOtherObject = @{ foo = 42
bar = $false ;
zaz = 3
}
</source>
 
Keys and values can be any .NET object type, e.g.
<source lang="text">
$now = [DateTime]::Now
$tomorrow = $now.AddDays(1)
$ProcessDeletionSchedule = @{
(Get-Process Notepad) = $now
(Get-Process calc) = $tomorrow
}
</source>
 
 
It is also possible to create an empty associative array and add single entries or even other associative arrays to it later on.
Line 969 ⟶ 989:
$phonebook.Remove('Sally Smart')
</source>
 
Hash tables can be added, e.g:
 
<source lang="text">
$hash1 = @{ a=1;b=2}
$hash2 = @{ c=3;d=4}
$hash3 = $hash1 + $hash2
</source>
 
== References ==