due to the initialization of variable it is only possible to create app variables, and storage or cloud variables. All of them are global to the app.
But what, if I want to create local variables (e.g. help variables) inside a function. I do not mean the parameters, they are local. I mean additional local variables.
I have long made the request for these blocks, but no information about when they will appear, or if they appear at all I do not have.
As a workaround, you can do this: call the function block parameters prefixed with _ (as it was done in Javascript before the let declarations), and when the function set its value to undefined.
Thank you actech.
But the problem is, that there is only the initialize app block for variable definition.
When teaching this to students I cannot use a workaround like yours, because they cannot initialize local variables within the function block. But for teaching computer science in a class it is important to know the difference between local and global data.
We definitely want to keep improving the platform, but I’m not aware of any plans to add in local variables.
@rollke is there anything that the current offering of variables does not allow you to do? i.e. is the lack of local variables preventing your from completing some important aspect of your app at the moment?
ok - this is a fair point!
I think what you’re really asking for here @kartik14 is for faster variables, no?
As mentioned above, we’re keen to keep improving the platform but at this stage have to prioritise the features that are preventing users from completing their projects.
If the absence of a component/property is not blocking users from building their app then it gets added to the queue, but with a lower priority.
Imitation of a local variable. To create a local variable, you must create a function parameter with the same name as the variable block from the function parameter.
No, the method I showed is called like this - turning a global variable from a parameter of function into a local variable. Unfortunately, this is the maximum that can be achieved from Thunkable X.
If student training is based on Thunkable X, then the teacher will often have to say that this or that mechanism of work is specific to the Thunkable X platform and in programming languages it works differently or there is no such concept at all.