Open
Description
We should support local variable to be able to cache intermediate computation result in a binding.
So we could do things like
function foobar() -> int {
let value = compute-value();
return value != 0 : root.property / value ? root.some-other-value;
}
In other word, add support for
let something = <expression>;
in the Slint language.
Discussed in #2751
Originally posted by loloof64 May 18, 2023
Hi, is it possible to define local variables in ui scripts components/functions ?
I mean something like this for example
export component MySquare inherits Rectangle {
width: 100px;
height: 100px;
background: red;
in property<string> items: "abcd/efgh/ijkl/mnop";
public function get_items_arr() -> [string] {
let arr = [];
for elt in items {
if (elt != "/") arr.push(elt);
}
arr
}
}
```</div>