Conditional Operator.

The syntax in Flex for conditional operator is same as that of the other technologies like c,java,.., for newbies the syntax is here.

Syntax:

Condition?(condition=true)statement:condition=false)statement.

Or

Condition?true satement:false statement.

It is nothing but a if.. else.. block in one single line.

Example in Flex:

Private function conopeExample():void

{

txtname.text=4>1?”Kumar”:”gandhi”;

}

<mx:TextInput id=”txtname” />

<mx:Button id=”btn” click=” conopeExample” />

The conditional operator is so simple that we programmers ignore that , or not interested in that. But it’s so simple that a good programmer will use to reduce the lines of code in the Application. Finally it’s synonym of our if .. else .. statements.

Enjoy the Post.

Leave a Reply