Check if the object is a compile-time constant

I am trying to write a function that will do the following:

isConstant(new Obj()) => false
isConstant(const Obj()) => true

Is it possible?

+4
source share
1 answer

No.

At run time, there is no difference between the compile-time constant value and the new object that you just created. The difference exists only at compile time.

, , , . (x) => identical(const Object(), x); const Object() Object(), . , , , , . / "const" , ( , , ).

, ?

+5

All Articles