-
Notifications
You must be signed in to change notification settings - Fork 0
Features Variable Scope
Kameron Brooks edited this page Aug 17, 2019
·
1 revision
CCL supports block scoping
string s = "hello";
{
string t = s + " world"; // t = "hello world"
}
print(t); // t is undefined in current scope
That means for loops, while loops, if statements, else statements, and elseif statements have their own scope. Variables declared inside of a block { }
are not available outside of the brackets.
for(int i=0; i < 10; i += 1) {
print(i); // i is defined
}
print(i) // i is not defined in current scope
Questions? Comments?
Contact me at kameron@creation-wasteland.com
Follow on Twitter: @wasteland_11
Copyright 2019 © Kameron Brooks