Post #2195232
2025-09-17 11:58 UTC
@b_viguier@phpc.social
yes... there is a difference in the way the Garbage Collection works
in theory, if I am to unset an object that is used as key, I think I prefer the Weakmap approach, where it also removes the entry from the map
BUT...
and this I did not know... when using an ENUM, the behavior is the same in both cases and the entry in the maps are preserved:
see here:
https://3v4l.org/tpnsc#v8.4.12
Replies (1)
-
@Crell@phpc.social 2025-09-17 17:11
@dgoosens@phpc.social @b_viguier@phpc.social Correct, because the enum case is a global instance that is never destroyed, and thus the Weakness of the map is never triggered.