Question

What does the empty curly braces constraint mean? For example (taken from the ObjectMap implementation of Map):

extern class ObjectMap < K: { }, V > implements Map.IMap<K,V> {
...
Was it helpful?

Solution

A type parameter of {} matches any object. This includes class instances, anonymous objects etc, but excludes Ints, Floats, Bools and other basic types.

A type parameter of Dynamic on the other hand matches both objects and ints, floats, bools etc.

(Please note: as @back2dos pointed out, a String counts as a class instance, so will satisfy the type constraint {})

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top