Frage

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> {
...
War es hilfreich?

Lösung

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 {})

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top