Hi,
I'm declaring this constant map:
static const Map powerOf2 := Int:Int[8:2.pow(8), 16:2.pow(16), 24:2.pow(24)]
then when I try to use this map in a method where x is an Int, like this:
return x / powerOf2[16]
The compiler complains:
Ambiguous operator method: sys::Int / sys::Obj [divDecimal, div, divFloat]
How is this ambiguous if map values are of Int type. Or aren't they? What am I doing wrong, please?
The type which matters is the type of your field, which is Map. It should be:
static const Int:Int powerOf2 := [8:2.pow(8), 16:2.pow(16), 24:2.pow(24)]
It makes sense now, Thank you!
Login or Signup to reply.
ortizgiraldo Sun 13 Jan 2013
Hi,
I'm declaring this constant map:
then when I try to use this map in a method where x is an Int, like this:
The compiler complains:
How is this ambiguous if map values are of Int type. Or aren't they? What am I doing wrong, please?
brian Mon 14 Jan 2013
The type which matters is the type of your field, which is Map. It should be:
ortizgiraldo Mon 14 Jan 2013
It makes sense now, Thank you!