NewMap Test()
Debug MapSize(Test())
; Add a member "A" to the map
; the expected map size is 1, OK
Test("A") = 1
Debug MapSize(Test())
; Check the value of a non-existent member
; the expected map size is still 1, BUT...
; a new member "B" is automatically created and added to the map!
If Test("B")
Debug "B <> 0"
EndIf
Debug MapSize(Test())
Is this correct behavior or a bug? In my opinion the map size should only increment when assigning new values...
Am I wrong or is this a bug?
As you walk on by, Will you call my name? Or will you walk away?
Test("B") does not add a new element.
The behaviour is inconsistent.
Regardless whether it makes sense to automatically create an entry in the map, this behaviour is not inconsistent. With the Debug in front of the line, Test("B") is a rhs-term and so no new element is assigned to the map.
Last edited by Josh on Sat Feb 16, 2019 12:32 pm, edited 1 time in total.