If / Else
If else works identically to how it does in C#, the added optional ability to be declared as destructive
A scope in Evolve is both lexical (so starts/ends with {
and }
). Scopes within render
have a lifetime and any state
defined in a lexical scope will be remembered from frame to frame.
A destructive
scope will be cleaned up if it does not render for a frame. This can be useful
when you have some state that is only valid while its part of the UI on screen or if you have a large
tree of elements that are rarely used, it can be good practice to cleanup the tree when its not
in use to release memory and other resources.
template IfElseSample(required bool someCondition, required bool someOtherCondition) render {
if(someCondition) {
Text("one");
}
else if(someOtherCondition) {
Text("two");
}
else {
Text("three");
}
}
template IfElseSampleDestructive(required bool someCondition, required bool someOtherCondition) render {
if:destructive(someCondition) {
Text("one");
}
else if(someOtherCondition) {
Text("two");
}
else {
Text("three");
}
}