-
-
Save bielawb/dafd69de42e185958769f5cc2129783c to your computer and use it in GitHub Desktop.
Świadome operowanie na zmiennej przez referencję
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Add-BarInfo { | |
param ( | |
[hashtable]$Bary, | |
[string]$Nazwa, | |
[Int]$IlePiw | |
) | |
if ($Bary.Contains($Nazwa)) { | |
$Bary.$Nazwa += $IlePiw | |
} else { | |
$Bary.$Nazwa = $IlePiw | |
} | |
} | |
$mojeBary = @{} | |
Add-BarInfo -Bary $mojeBary -Nazwa Miś -IlePiw 2 | |
Add-BarInfo -Bary $mojeBary -Nazwa Tani -IlePiw 5 | |
Add-BarInfo -Bary $mojeBary -Nazwa Miś -IlePiw 2 | |
$mojeBary.Miś | |
<# | |
Na wyjściu: | |
4 | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment