Remove all items from an array that don't meet a specific criteria.
Example 2. Filtering arrays
Import sodaware.blitzmax_array
Local colours:String[] = [ ..
"Red", ..
"Orange", ..
"Yellow", ..
"Green", ..
"Blue", ..
"Indigo", ..
"Violet" ..
]
' Create a new array that only contains items with 6 letters or more
Local long_colours:Object[] = Array_Filter(colours, IsLongWord)
' Array will now contain the following:
' ["Orange", "Yellow", "Indigo", "Violet"]
' Function to test if a string is 6 or more letters long
Function IsLongWord:Byte(word:Object)
Return ( word.ToString().Length >= 6 )
End Function