You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The when keyword makes code run when a variable mutates.
So, using the functionality of said keyword, we can make it run code that mutates the variable which runs the code.
Here's an example implementation (with a limit so the code doesn't go haywire):
// Initiate our variablevarvari=-1!// when i variable mutates, run the code blockwhen(i>-2){// check if its less than 5if(i<5){// print i then add 1 to itprint(i)!i=i+1!}}// add 1 to i to initiate the loopi=i+1!
Unfortunately limiting the number of times when runs code when a variable mutates can cause some problem in code that uses it in the correct way.
So, how would you go about avoiding this kind of loop in DreamBerd?
The text was updated successfully, but these errors were encountered:
The
when
keyword makes code run when a variable mutates.So, using the functionality of said keyword, we can make it run code that mutates the variable which runs the code.
Here's an example implementation (with a limit so the code doesn't go haywire):
Unfortunately limiting the number of times
when
runs code when a variable mutates can cause some problem in code that uses it in the correct way.So, how would you go about avoiding this kind of loop in DreamBerd?
The text was updated successfully, but these errors were encountered: