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

Sass: Variables (Documentation) #669

Closed
aiman99aleryany opened this issue Sep 11, 2022 · 2 comments · Fixed by #681
Closed

Sass: Variables (Documentation) #669

aiman99aleryany opened this issue Sep 11, 2022 · 2 comments · Fixed by #681

Comments

@aiman99aleryany
Copy link

I am not sure if I should write this issue here, but here we go!
image
as you see in this picture from the documentation of sass here about the variables. It says that flow control statements can't create/declare new variables, which is not true

@if 1 {
 $index: 20px;
 @debug $index;
}
@for $i from 1 through 4 {
  $index: 20px;
  @debug $index;
}

In both cases above, the variables are declared and debugged without prompting any errors, as long as I am using the variables inside the flow control.. maybe you should specify that in the documentation because it creates some confusion for beginners like me. have a great day!

@WebMechanic
Copy link

.. but they can't declare new variables there.

the key word is "there" -- in the outer scope, not that they can't declare variables at all.
They sure can within their inner scope, which is what your code perfectly depicts.
In order to change a "global" or "outer scope" variable it needs to exist *there first.

$index: 10px;
@debug $index; // 10px

@if 1 {
 $index: 20px;
}
@debug $index; // 20px

@aiman99aleryany
Copy link
Author

aiman99aleryany commented Sep 13, 2022

@WebMechanic
Thank you for your kind reply.. I understand what it meant now, if they could make it clearer in the documentation to the Non-native English speakers. By specifying that *there keyword references the global scope. Thanks in advance.

@jathak jathak transferred this issue from sass/sass Sep 13, 2022
jathak added a commit that referenced this issue Oct 17, 2022
jathak added a commit that referenced this issue Apr 5, 2023
asaf400 pushed a commit to asaf400/ass-site that referenced this issue Apr 18, 2024
asaf400 pushed a commit to asaf400/ass-site that referenced this issue Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants