I was referring function casting when I talked about the runtime error that
occurs when it fails. I use that type of casting very frequently.

- Josh
On Jan 7, 2016 5:27 PM, "Alex Harui" <aha...@adobe.com> wrote:

>
>
> On 1/7/16, 2:11 PM, "Josh Tynjala" <joshtynj...@gmail.com> wrote:
>
> >There are times when I consider it convenient to use "as" for casting and
> >check for null, but it's not frequently. Usually, I use "is" instead. Most
> >of the time, I use the other form of casting that results in a runtime
> >error when the cast fails. I hope that runtime error won't be removed. Or
> >at least could be turned on globally during debugging.
>
> Not sure which runtime error you are referring to.
>
> >
> >In regards to 2, is it not possible to walk the prototype chain of any
> >JavaScript object? Or am I misunderstanding?
>
> IIRC, instanceof was recently added to Language.is/as, but I think it
> won't work for interfaces.
>
> Another related question:  How many of you use "function" casting and
> expect it to fail?  As in:
>
>   var foo:SomeType = SomeType(somevar);
>
> Or
>
>   var bar:String = SomeType(somevar).someStringProperty;
>
> This also gets used to make the compiler happy and seems more readable
> than:
>
>   var bar:String = (somevar as SomeType).someStringProperty;
>
> If "SomeType(somevar)" is not in a try/catch it will throw an exception.
> How often are you relying on that vs just trying to make the compiler
> happy?
>
>
> -Alex
>
>

Reply via email to