Map type question
brian
15 Apr 2012
In your example this line:
Map data := ["x": null]
The type of the variable is explicitly typed as Map, not Str:Obj?. The actual map it references is typed Str:Obj?, but not the variable itself. If you used type inference, then map would have the type you expect:
data := ["x": null]
Although there is still a sort of bug there in that an unparameterized Map should still return V? for get. There is still a few rough edges using unparameterized generic types like that.
paul
15 Apr 2012
Just to make things clear for myself. Here's an example
class HelloFantom { Void main() { Map data := ["x": null] z := data.get("x") ?: 2 echo(z) } }This code doesn't compile throwing:
It seems that the compiler fails to detect the right type of map
datawhich is[Str:Obj?]. Thus if you try to compile and run this code:class HelloFantom { Void main() { Map data := ["x": null] echo(data.typeof) } }The output will be
Is this a bug?