Hello,
I’m pretty new in the Haxe ecosystem and I don’t understand why this piece of code is failing with a “should be Int” compilation error:
class Test {
static function main() {
var v1 = new Vec2(1, 2);
v1 * 2.0;
trace(v1.x + " " + v1.y);
}
}
class Vec2
{
public inline function new(x : Float, y : Float) {
this.x = x;
this.y = y;
}
@:op(A * B) @:commutative
public inline function multiply(B : Float) : Vec2 {
return new Vec2(x * B, y * B);
}
//@:op(A * B) @:commutative
//public static function multiply(A:Vec2, B:Float):Vec2 {
// A.x *= B;
// A.y *= B;
// return A;
//}
public var x:Float;
public var y:Float;
}
This can easily tested in https://try.haxe.org
Thanks in advance for your help.
Best,
Aurélien