« PHP 8.3 Manual トップ
著作権 »
per page, with , order by , clip by
Results of 1 - 1 of about 1 for LineIterator (0.001 sec.)
ジェネレータと Iterator オブジェクトとの比較 | PHP 8.3 9414
ジェネレータと Iterator オブジェクトとの比較 ジェネレータの最大のメリットは、シンプルに書けることです。 Iterator を実装するのに比べて、必要な決まり文句の数がかなり少なくなります。 また、ジェネレータを使ったコードのほうが、一般的に読みやすく ... !== $line = fgets ( $fileHandle )) { yield $line ; } fclose ( $fileHandle ); } // これを、下のクラスと比べてみると…… class LineIterator implements Iterator { protected $fileHandle ; protected $line ; protected $i ; public function __construct ( $fileName ) { ...
https://man.mtool.work/php/8.3/language.generators.comparison.html
PREV 1 NEXT