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

Reply via email to