#2081 Ambiguous operator method on Int:Int map

ortizgiraldo Sun 13 Jan 2013

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?

brian Mon 14 Jan 2013

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)]

ortizgiraldo Mon 14 Jan 2013

It makes sense now, Thank you!

Login or Signup to reply.