Ok, thanks. Yes that makes sense. I was thinking that it might be a slight enhancement to speed up execution time of a function.

Jiri



On 05-08-10 19:20, Juan Pablo Califano wrote:
The difference is that the reference is constant, meaning you cannot change
it.

You can't do this:

const my_var:String = "my_var";

my_var = "other text";

You could do this if it were declared as a var.

Cheers
Juan Pablo Califano

2010/8/5 Jiri<[email protected]>

I have a simple question. I came across some code in a project that defines
a const in a function.

function doSomething():void{
        const my_var:String = "my_var"

        var buffer:String = '';

        for(var i:int = 0 ; i<list.length ; i++){
                buffer += list[i] + my_var
        }
}

What is the difference compared to this:

function doSomething():void{
        var my_var:String = "my_var"
        var buffer:String = '';

        for(var i:int = 0 ; i<list.length ; i++){
                buffer += list[i] + my_var
        }
}

Regards,

Jiri
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to