Change the example for NextMapElement() and ResetMap()

Found an issue in the documentation ? Please report it here !

Moderator: Documentation Editors

User avatar
STARGÅTE
Addict
Addict
Posts: 2228
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Change the example for NextMapElement() and ResetMap()

Post 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.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2139
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

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

Post 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.
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
Post Reply