Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable scope issue in loops #138

Open
LeighBicknell opened this issue Jan 15, 2014 · 0 comments
Open

Variable scope issue in loops #138

LeighBicknell opened this issue Jan 15, 2014 · 0 comments

Comments

@LeighBicknell
Copy link

Example:

$Base:1.618;
$Exponent:4;

$Rtn: $Base;

@for $i from 1 to $Exponent
{
    $Rtn: $Rtn * $Base;
    $DeclaredInLoop: $Rtn;
    #supertest2{test:$Rtn;}
}
#supertest3{test:$Rtn;DeclaredInLoop:$DeclaredInLoop;}

This outputs

#supertest2{test:2.618}
#supertest2{test:4.326}
#supertest2{test:6.854}
#supertest2{test:11.089}
#supertest3{test:1.618;DeclaredInLoop:false;}

You can see that after it exits the loop $Rtn has returned to it's original value, instead of maintaining the value it has by the end of the loop (11.089). And the $DeclaredInLoop variable simply returns false outside of the loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant