RE: [flexcoders] Short-circuiting logical operators in AS3?

2007-04-12 Thread Alex Harui
I know it works for  



From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of jandersen1978
Sent: Wednesday, April 11, 2007 8:58 PM
To: [EMAIL PROTECTED]
Subject: [flexcoders] Short-circuiting logical operators in AS3?



I'm fairly new to AS3 coming from a javascript background. I noticed
that I get an error when running the if statement below because
dataProvider[i].data doesn't exist. 

if ( true || val == dataProvider[i].data) {
selectedIndex = i;
return;
} 

In javascript the double OR operator (||) short-circuits such that
it wouldn't evaluate the second part of the term in the if expression
after finding the first term true. This doesn't seem to be the case
with AS3. Does AS3 support short circuiting logical operator? Is
there another way to get short-circuiting statements in AS3? (I know
I could rewrite the If statement as a two nested ifs...) anything I'm
missing as a newcomer? This is not a big deal of course, just curious...



 


Re: [flexcoders] Short-circuiting logical operators in AS3?

2007-04-12 Thread Troy Gilbert

Yeah, it definitely works for , I depend on it all the time. Not sure if
I've specifically tried it with || though...

Troy.


On 12 Apr 2007 09:43:36 -0700, Alex Harui [EMAIL PROTECTED] wrote:


   I know it works for  

 --
*From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] *On
Behalf Of *jandersen1978
*Sent:* Wednesday, April 11, 2007 8:58 PM
*To:* [EMAIL PROTECTED]
*Subject:* [flexcoders] Short-circuiting logical operators in AS3?

 I'm fairly new to AS3 coming from a javascript background. I noticed
that I get an error when running the if statement below because
dataProvider[i].data doesn't exist.

if ( true || val == dataProvider[i].data) {
selectedIndex = i;
return;
}

In javascript the double OR operator (||) short-circuits such that
it wouldn't evaluate the second part of the term in the if expression
after finding the first term true. This doesn't seem to be the case
with AS3. Does AS3 support short circuiting logical operator? Is
there another way to get short-circuiting statements in AS3? (I know
I could rewrite the If statement as a two nested ifs...) anything I'm
missing as a newcomer? This is not a big deal of course, just curious...

 



RE: [flexcoders] Short-circuiting logical operators in AS3?

2007-04-12 Thread Gordon Smith
I tried || and it short-circuits for me. Please post a complete miniapp
with a case that doesn't work.
 
- Gordon



From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Troy Gilbert
Sent: Thursday, April 12, 2007 9:49 AM
To: [EMAIL PROTECTED]
Subject: Re: [flexcoders] Short-circuiting logical operators in AS3?



Yeah, it definitely works for , I depend on it all the time. Not sure
if I've specifically tried it with || though...

Troy.



On 12 Apr 2007 09:43:36 -0700, Alex Harui [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote: 



I know it works for  



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] http://yahoogroups.com ] On Behalf
Of jandersen1978
Sent: Wednesday, April 11, 2007 8:58 PM
To: [EMAIL PROTECTED]
Subject: [flexcoders] Short-circuiting logical operators in AS3?




I'm fairly new to AS3 coming from a javascript background. I
noticed
that I get an error when running the if statement below because
dataProvider[i].data doesn't exist. 

if ( true || val == dataProvider[i].data) {
selectedIndex = i;
return;
} 

In javascript the double OR operator (||) short-circuits such
that
it wouldn't evaluate the second part of the term in the if
expression
after finding the first term true. This doesn't seem to be the
case
with AS3. Does AS3 support short circuiting logical operator? Is
there another way to get short-circuiting statements in AS3? (I
know
I could rewrite the If statement as a two nested ifs...)
anything I'm
missing as a newcomer? This is not a big deal of course, just
curious...