### Map Iteration

Example iterating over a map by using properties Values and Keys.
Note:
The methods GetKeyAt and GetValueAt should not be used.
Example WeekDays
Dim WeekDays As Map = CreateMap(1: "Monday", 2: "Tuesday", 3: "Wednesday", 4:"Thursday", 5: "Friday", 6: "Saturday", 7: "Sunday")
'Iterate over the map values
For Each WeekDay As String In WeekDays.Values
Log(WeekDay)
Next
'Iterate over both map keys and values
For Each WeekDayNumber As Int In WeekDays.Keys
Dim WeekDay As String = WeekDays.Get(WeekDayNumber)
Log($"Weekday number: ${WeekDayNumber}, value: ${WeekDay}"$)
Next
Example Key:Value pair
' Return a string listing Key:Key,Value:Value separated by CRLF
`Private Sub Map_ToString(m As Map) As String
Dim sb As StringBuilder
sb.Initialize
' Iterate over keys and values
For Each Key As String In m.Keys
Dim Value As String = m.Get(Key)
sb.Append($"Key: ${Key}, value: ${Value}"$).Append("
")
Log($"Key: ${Key} = Value: ${Value}"$)
Next
Return sb.tostring
End Sub`

Changed: 2018-05-27 09:38, Category: Map, File: T6C217M1598.htm, ID: 1598