I have a theoretical problem - how to refer to a hash table during its initialization, for example, to calculate members based on other members already declared.
Remove-Variable myHashTable -ErrorAction Ignore $myHashTable = @{ One = 1 Two= 2 Three = ??? # following expressions do not work # $This.One + $This.Two or # $_.One + $_.Two # $myHashTable.One + $myHashTable.Two # ???? } $myHashTable.Three -eq 3 # make this $true
Any ideas how to do this? Is it possible?
Edit: This was my solution:
$myHashTable = @{ One = 1 Two= 2 } $myHashTable.Three = $myHashTable.One + $myHashTable.Two
source share