Android Question How to get/asign returned Map from Sub

Jason Wood

Member
Licensed User
Hi,

I have a Sub which returns a map

Code: Copy
Sub calculateResults(reactionTime As Int)
    Private gameResults As Map
    ...
    Return gameResults
End Sub

I want to use the returned map when this Sub is called i.e

Code: Copy
Sub otherSub
    ...
    Dim getGameResults As Map
    getGameResults.Initialize
    getGameResults = calculateResults(reactionTime)
End Sub

But this give an error at compile time.

Code: Copy
B4A line: 211
getGameResults = calculateResults(reactionTime)
javac 1.8.0_131
src\b4a\example\main.java:1113: error: incompatible types: String cannot be converted to MyMap
_getgameresults.setObject((anywheresoftware.b4a.objects.collections.Map.MyMap)(_calculateresults(_reactiontime)));

What am I doing wrong?
 
Default is to return a String if you don´t specify it.

Code: Copy
Sub calculateResults(reactionTime As Int) As Map ' <--- !!!
    Private gameResults As Map
    ...
    Return gameResults
End Sub
 
Upvote 0
Back
Top