4 ms·
Actually, here's an example of precisely why maps are not passed as references: https://go.dev/play/p/-mEeg2Ud68V https://go.dev/play/p/-mEeg2Ud68V This examp
by B-Con 2y ago
Actually, here's an example of precisely why maps are not passed as references:
https://go.dev/play/p/-mEeg2Ud68V https://go.dev/play/p/-mEeg2Ud68V
This example cannot re-allocate the original map! If the map were truly passed by reference, it could be allocated in a local function. But it can't, only values within the map can be modified when a map is passed.
This is in contrast with pass by reference in, say, C++, in which case you can assign directly to and modify the reference. ex: https://www.ibm.com/docs/en/zos/2.4.0?topic=calls-pass-by-reference-c-only https://www.ibm.com/docs/en/zos/2.4.0?topic=calls-pass-by-re...