mithlond
10/22/2024, 8:51 PMblah = structNew()
blah.a = 1
blah.b = 2
years ago. Now using more like blah = { a = 1, b = 2}
. My question is which of these two this (newer way using inline struct literal) would translate to under the hood:
// Door No. 1
blah = structNew()
blah.a = 1
blah.b = 2
// Door No. 2
_someSHAhashTemp = structNew() // just guessing here; the actual implementation isn't important, just the order of operations
_someSHAhashTemp.a = 1
_someSHAhashTemp.b = 2
blah = _someSHAhashTemp
That is, when the actual assignment operator is handled to set blah
, is it given the fully-baked struct that already has keys a
and b
, or is it pointed at a new empty struct which is then populated?bdw429s
10/22/2024, 8:52 PMbdw429s
10/22/2024, 8:53 PMbdw429s
10/22/2024, 8:53 PMbdw429s
10/22/2024, 8:54 PMfoo = [ "brad" : "wood", "luis" : "majano" ];
mithlond
10/22/2024, 8:57 PMblah
points, for a very brief time, to an empty struct.bdw429s
10/22/2024, 8:57 PMbdw429s
10/22/2024, 8:57 PMmithlond
10/22/2024, 8:58 PMbdw429s
10/22/2024, 8:58 PMmithlond
10/22/2024, 8:58 PMbdw429s
10/22/2024, 8:58 PMbdw429s
10/22/2024, 8:58 PMbdw429s
10/22/2024, 8:59 PMmithlond
10/22/2024, 9:00 PMblah = {c: 3, d: 4}
blah = {a: 1, b: 2}
mithlond
10/22/2024, 9:00 PMbdw429s
10/22/2024, 9:00 PMmithlond
10/22/2024, 9:01 PMbdw429s
10/22/2024, 9:01 PMbdw429s
10/22/2024, 9:01 PMmithlond
10/22/2024, 9:01 PMmithlond
10/22/2024, 9:03 PMbdw429s
10/22/2024, 9:17 PMbdw429s
10/22/2024, 9:17 PMbdw429s
10/22/2024, 9:18 PMbdw429s
10/22/2024, 9:18 PM