[haXe] Request for a 'const' modifier

Nicolas Cannasse ncannasse at motion-twin.com
Thu Dec 14 18:46:52 CET 2006


> What does the  +  do?
> 
> Where is this mentioned in the docs? Is this new in 1.09?
> I've never seen this before :-|

+ and - in type parameters are variance anotation.
It can be useful to write a template code where argument types might be
variable. It's a very advanced feature so is not documented.

For example

function f( x : Array<+MyClass> ) {
}

Means that you can use 'f' with arrays of subclasses of MyClass as well,
but the Array will be readonly since you can't insert a MyClass instance
in an array of a subclass of it.

Nicolas



More information about the Haxe mailing list