Say just for fun I want to override Array
and redefine map
:
public dynamic class MagicArray extends Array {
public override function map(f:Function, thisObject:* = null):Array {
var result:Array = [];
for (var i:int = 0; i < this.length; i++) {
result.push(f(this[i]));
}
return result;
}
}
We get this error: Method marked override must override another method.
Huh?
So I stripped the override
keyword and tried again. Now, everything compiles fine. But if we try to use it:
var a:MagicArray = new MagicArray([1,2,3]);
a.map(function(x) { return x + 1; });
We get the following error:
Error: Ambiguous reference to map.
So what's going on here? How can I override map
?