utils icon indicating copy to clipboard operation
utils copied to clipboard

iteration over ArrayHash with reference

Open Ciki opened this issue 4 years ago • 1 comments

Hi @dg, this hotfix breaks iteration over ArrayHash with reference, which is quite unpredictable until one looks into the code..

$hash = \Nette\Utils\ArrayHash::from([1]);
foreach($hash as $k => & $v) {
    $v = 2;
}
dump($hash);

result

Nette\Utils\ArrayHash
0: 1

I don't know if that can be fixed somehow, but at least it could be mentioned in doc for newcomers

Ciki avatar May 28 '21 11:05 Ciki

I can't think of a way to fix it, but feel free to add it to the documentation.

dg avatar Sep 12 '22 23:09 dg

Ping @Ciki

dg avatar Jan 15 '23 11:01 dg