typedef Length = {
  var length(default, null):Int;
}

class Test {
    static function main() {
        trace("Length of a String: " + length("Hello world") + " and * 2 " + length2("Hello world"));
        trace("Length of an Array: " + length([0, 3, 5, 2, 1]) + " and * 2 " + length2([0, 3, 5, 2, 1]));
        //trace("This will throw a runtime error: " + length(3));
    }
    
    static inline function length<T:Length>(o:T) {
        return o.length;
    }
    
    static inline function length2<T:Length>(o:T) {
        return o.length * 2;
    }
}