代入演算子の結合性
代入演算子の結合性のテスト
b = a = 10.5の場合
b = (a = 10.5);
右辺結合性なので、b=10 になると思っていたんだが、、なんで
intどうしの割り算
a/cの結果はint型になると思っていたんだが、Number型に変換されるみたい、、
♥0 |
Line 31 |
Modified 2009-06-24 16:50:07 |
MIT License
archived:2017-03-20 06:47:11
ActionScript3 source code
/**
* Copyright alotfuck ( http://wonderfl.net/user/alotfuck )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/yG9a
*/
package {
import flash.display.Sprite;
import flash.text.*;
/**
*
* 代入演算子の結合性のテスト
*
* b = a = 10.5の場合
*
* b = (a = 10.5);
* 右辺結合性なので、b=10 になると思っていたんだが、、なんで
*
* intどうしの割り算
* a/cの結果はint型になると思っていたんだが、Number型に変換されるみたい、、
*
*/
public class FlashTest extends Sprite {
public function FlashTest() {
var a:int;
var b:Number;
var c:int=3;
a = b = 10.5;
var output:String="a = b = 10.5 >> a : "+a+" , b : "+b;
var txt:Text =new Text (10,10,output,this);
b = a = 10.5;
output="b = a = 10.5 >> a : "+a+" , b : "+b;
txt=new Text (10,30,output,this);
output="a/c = "+a/c;
txt=new Text (10,50,output,this);
}
}
}
import flash.text.*;
import flash.display.*;
class Text extends Sprite{
public function Text(x:Number,y:Number,value:String,parent:Sprite){
var txt:TextField=new TextField();
txt.text=value;
txt.x=x;
txt.y=y;
txt.width=200;
parent.addChild(txt);
}
}