You can see the example here:
It would be lucky for me if they use Java's Map type, because there is a Fantom Map type to map with it. The problem is they used their own Map type:
I have no idea how to translate this:
public void startup(Display display, Map<String, String> properties)
to Fantom code.
Any attempts of mine always resulted in type mismatch error.
The simple answer is you don't. Java generics are erased, so when working with Java code thru the Java FFI you just work with them as unparameterized classes. For example:
map := HashMap()
Also look at the Interop class which provides utils to map b/w Fantom lists/maps and Java ones:
brian: The problem is this Java code:
How could I translate it to Fantom?
I have the override this method.
The parameter is explicitly said to be a Map<String, String>. I tried everything I could but it always resulted in a type not match error.
With type erasure, you should just need the Java class:
using [java]java.util::Map as JMap
Void startup(Display, JMap props)
Login or Signup to reply.