02-03-2023, 03:52 AM
That may run fine for a time. And yes, you were able to gain the value of MyModule:MyClass::A just fine.
However, recursion does occur. For any who wishes to go into their script editor and type this within the Main script (typically at the bottom), here is an example of said recursion being created:
I am able to receive output, not just from MyModule::MyClass. But from MyModule::MyClass:MyClass (which is the contents of MyModule thrown into MyClass), and the contents of MyModule::MyClass::MyClass::MyClass (again, throwing the contents back in once more).
Honestly, the recursion is so bad, I could use this for the output:
And with 15 instances of MyClass, one being within the previous over and over, it still yield the same result. The MyClass object is being duplicated over and over and over, taking up more memory as the program runs.
Anyone can try that example I posted and see for themselves.
However, recursion does occur. For any who wishes to go into their script editor and type this within the Main script (typically at the bottom), here is an example of said recursion being created:
Code:
module MyModule
class MyClass
A = 'A'
B = 'B'
include MyModule
end
end
p MyModule::MyClass::MyClass::MyClass::MyClass::B
I am able to receive output, not just from MyModule::MyClass. But from MyModule::MyClass:MyClass (which is the contents of MyModule thrown into MyClass), and the contents of MyModule::MyClass::MyClass::MyClass (again, throwing the contents back in once more).
Honestly, the recursion is so bad, I could use this for the output:
Code:
p MyModule::MyClass::MyClass::MyClass::MyClass::MyClass::MyClass::MyClass::MyClass::MyClass::MyClass::MyClass::MyClass::MyClass::MyClass::MyClass::MyClass::B
And with 15 instances of MyClass, one being within the previous over and over, it still yield the same result. The MyClass object is being duplicated over and over and over, taking up more memory as the program runs.
Anyone can try that example I posted and see for themselves.