forked from: Vectorのmap()がVectorを返さない気がするのですが

by matacat forked from Vectorのmap()がVectorを返さない気がするのですが (diff: 31)
♥0 | Line 25 | Modified 2010-04-02 03:07:25 | MIT License
play

ActionScript3 source code

/**
 * Copyright matacat ( http://wonderfl.net/user/matacat )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/tqro
 */

// forked from imajuk's Vectorのmap()がVectorを返さない気がするのですが
package
{
    import flash.text.TextField;
    import flash.display.Sprite;
    
    public class VectorMapTest extends Sprite
    {
        public function VectorMapTest()
        {
            //Vectorのmap()がVectorを返さない気がするのですが気のせいでしょうか?
            //期待する動作はVectorの要素の数値をインクリメントするものですが
            //map()の戻り値はnullです。
            //僕が何を勘違いしているのか誰か教えてください
            
// 正しくは undefined みたいですけど…
// う~ん、何なんでしょう。さっぱりお手上げです。
// ちょろっと調べてみたんですが、これがヒントになるかどうか…
// AS3 駆動部の中身らしいです。これまた私にはさっぱり。 - matacat
// 
// tamarin-central: core/Vector.as@fbecf6c8a86f
//   http://hg.mozilla.org/tamarin-central/file/fbecf6c8a86f/core/Vector.as
            
            var tf:TextField = addChild(new TextField()) as TextField;
            var v:Vector.<Number> = Vector.<Number>([ 1, 2, 3 ]);
            tf.appendText(v.toString() + "\n");
            tf.appendText(
                String(
                    v.map(
                        function(item:Number, index:int, v:Vector.<Number>):Number
                        {
                            tf.appendText(item.toString() + "\n");
                            return item + 1;
                        }
                    )
                )
            );
        }
    }
}