class Test {
    static function main() {
        trace("Passing an Array<Int>: " + add(Left([10, 20, 30])));
        trace("Passing an Int: " + add(Right(3)));
        
        // This will throw a compile time error
        //trace("Passing an Array<String>: " + add(Left(["a", "b", "c"])));
    }
    
    static function add(o:haxe.ds.Either<Array<Int>, Int>):Array<Int> {
        var a:Array<Int>;
        switch(o) {
            case Left(x): a = x;
          case Right(x): a = [for(i in 0...x) i];
        }
        
        a.push(100);
        a.push(300);
        
        return a;
    }
}