There seems to be an issue with the creation of the transitions Array, but I can't figure out why!
The text class
export enum STATE_ID { CGU, Initial, Previous, Question}
export enum CHOICE_ID {CGU_accepted, CGU_not_accepted}
export class STATE_MACHINE {
constructor (context: string) {
this.transitions_initialize()
}
put_transition (source: STATE_ID, target: STATE_ID, label: CHOICE_ID): void
{console.log(this.transitions.length.toString)
this.transitions[source][label] = target
}
private transitions: STATE_ID[][] = new Array()
private transitions_initialize(): void {
this.put_transition(STATE_ID.Initial, STATE_ID.Question,
CHOICE_ID.CGU_accepted)
this.put_transition(STATE_ID.Initial, STATE_ID.CGU,
CHOICE_ID.CGU_not_accepted)
}
}
new STATE_MACHINE("test")
The error
[Function: toString]
Z:\Documents\Phi\Developpement\TypeScript\test3\state_machine.js:45
this.transitions[source][label] = target;
^
TypeError: Cannot set property '3' of undefined
at STATE_MACHINE.put_transition (Z:\Docum................
Any thoughts on what might be causing this?