Page 1 of 1

Change the example for NextMapElement() and ResetMap()

Posted: Fri Dec 01, 2023 8:01 pm
by STARGĂ…TE
This is not really a bug, but a request to change the example codes for ResetMap() and NextMapElement()

At the moment, the example code and debug output is:

Code: Select all

NewMap Country.s()

  Country("US") = "United States"
  Country("FR") = "France"
  Country("GE") = "Germany"

  ResetMap(Country())
  While NextMapElement(Country())
    Debug Country()
  Wend
United States
France
Germany
This output could lead to the suggestion that the map elements are in the order in which they were created (like a linked list). But this isn't the case in general.
A more "random" output (compared to the order of creation) can avoid such miss conclusion.

Code: Select all

NewMap Country.s()

Country("GE") = "Germany"
Country("IT") = "Italy"
Country("FR") = "France"
Country("US") = "United States"

ResetMap(Country())
While NextMapElement(Country())
	Debug Country()
Wend
Italy
United States
France
Germany
One can also add an additional comment.

Re: Change the example for NextMapElement() and ResetMap()

Posted: Sun Feb 11, 2024 7:39 pm
by Andre
Thanks for the suggestion.

But as the output isn't printed in the manual it doesn't suggest (from my point of view), that it's keeping the order of inserting...
Of course I can extend the examples to add 4 elements instead of 3 elements, but I don't know if it's really needed!?

Expecially as there is also included this statement in the PB docs: Map overview
The inserting order of the elements is not kept when using a map (unlike a List) and therefore they can't be sorted.