dim m as map
dim i,Val as int
m=File.ReadMap(File.DirInternal,"myfile.ini")
Val=5
for i=0 to m.size-1
if m.ContainsKey(Val)=false then '(Always return false)
....
end if
next
This works:
B4X:
dim m as map
dim i,Val as int
dim TempVal as string
m=File.ReadMap(File.DirInternal,"myfile.ini")
Val=5
TempVal=Val
for i=0 to m.size-1
if m.ContainsKey(TempVal)=false then 'Works correctly
....
end if
next
I'm still a newbie and maybe I shouldn't call it bug... if you have other explanation please let me know.
Map.ContainsKey is not expected to do any type casting. A Map can hold any type of object as both keys and values so you must give it the correct type of object for it to work as expected. In your case ReadMap populates the Map with Strings as both keys and values so you must pass a String type to ContainsKey.