So I have had to move a script that was running in a SwiftUI View into it's own class function so that it could run in the background when the user closes the app and also did not stop when the user went to another view.
I'm assuming your monkey class (it should be Monkey, btw) has an initializer that has a side effect of starting the timer.
Initializers with side effects are kind of iffy. If the only purpose of this object is to start a timer, than why bother having an initializer on a class? It could have just been a free function.
Interesting that worked, is there any documentation that explains why this works.
In theory I get it as you need assign a class to a var or let or something like that I guess it's like NodeJS say I want to use a class inside another class I can do it and use it multiple time by assigning it to a var.
it's just a shortcut for let _ = ... which is the same as let x = ... where you are not interested in the variable "x" (if you used let x = ... instead compiler would then complain that "x is not used").
Normally you'd allocate an instance variable with non static properties, besides other things it will allow you to have different Monkey objects with different properties.