In the code below, I would pass the name of the object which is being constructed through the n parameter in order to create a record in the currentDialogue dictionary which would pair that object’s ID with its actual name. Assuming that the object has already been created and is referenceable when the constructor works on it.
class Node{
function Node (i : String, n : Node){
id = i;
currentDialogue *= n;*
- }*
- var id : String;*
}
If I wanted to construct an object:
n1 = Node (“Why have you returned?”,n1);
My question is twofold:
1. Is it possible to use a reference to the object which is currently being constructed in the constructor for that object’s class?
2. If it is possible, Is there a better method than what is used in my sample code?