per curiosita' mi sono messo a fare un paio di prove:
posto l'esempio:
come vedete le 3 righe sono commentate perchč non sono riuscito nel mio intento che quello di far puntare eof a elenco.atEnd().codice:<script language="JavaScript"> function Lista(MyCollection) { this.riempi = function riempi(MyCollection) {this.elenco = new Enumerator(MyCollection);} //this.eof = this.elenco.atEnd(); //this.eof = function eof() { return (this.elenco.atEnd()) } //this.eof = function eof() { if (this.elenco.atEnd()) {return true;} else {return false;} } return this; } var arr = new Array("Ciao","questa","č","una","prova"); var test = new Lista; test.riempi(arr); var tmp = ""; //alert("eof = " + test.eof); while (!test.elenco.atEnd()) { tmp += test.elenco.item() + "\n"; test.elenco.moveNext(); } alert(tmp); </script>
Allo stesso modo poi rimapparei item, movenext,movefirst all'oggetto interno elenco in modo da avere questo output:
P.s l'esempio di enumerator č solo un test di studio, so che in questo caso farei prima ad usare l'oggetto enumerator direttamente, č solo per sapere come si puo' rimappare un oggetto.codice:while (!test.eof) { tmp += test.item() + "\n"; test.moveNext(); }

Rispondi quotando