Code: Select all
(setq struct (lambda (key value)
(block (theStruct)
; theStruct is always Nil at this point
(setq theStruct {})
; theStruct is the empty struct only on the first call
(setItem theStruct key value)
theStruct
)
))
; First call to function behaves as expected:
(struct "test" 4) -> {test:4}
; Second call returns same structure reference:
(struct "same" 5) -> {test:4 same:5}