Like in topic - what are the weirdest or very unusual syntax features you saw in other languages than Java? Please post features only from “real” languages (no Malborge, Shakespeare etc.).
I will start with this code snippet from Haxe:
class Vec3 {
public var x : Int;
public var y : Int;
public var z : Int;
public function new(?x : Int, ?y : Int, ?z : Int) {
this.x = (x == null) ? 0 : x;
this.y = (y == null) ? 0 : y;
this.z = (z == null) ? 0 : z;
}
}
Haxe don’t support method and constructor overloading, but what we see there is something similar - in this case this method can be invoked without parameters or with 1, 2 or 3 parameters, like this:
new Vec3(); // (0, 0, 0)
new Vec3(1); // (1, 0, 0)
new Vec3(1, 2); // (1, 2, 0)
new Vec3(1, 2, 3); // (1, 2, 3)