What is the difference between flex – var t: myclass = myclass (o); and var t: myclass = o acts as Myclass;

What is the difference between this type of conversion expression? What is better?

// One way
var t:MyClass = MyClass(o);
// Another
var t:MyClass = o as MyClass;

Oh, I knew that one before…

Ok, if it cannot be converted to MyClass, the first one will fail, i.e. you will end up with an exception flying your stack.

The second one will never be thrown if If you can’t perform proper projection, you will only end up with a null value.

I think.

What is the difference between this type of conversion expression? ? What is better?

// One way
var t:MyClass = MyClass(o);
// Another
var t:MyClass = o as MyClass;

Oh, I knew that one before…

Ok, if it can’t be converted to MyClass, the first one will fail, i.e. you will end up with an exception flying your stack.

The second one will never be thrown, if you can’t cast properly, you will only end up with one Null value.

I think.

Leave a Comment

Your email address will not be published.