Modern PHP
Generators
Generators are similar to iterators that calculate their values on demand, thus potentially using fewer resources. They can be created using the yield
keyword, e.g.:
function my_generator() { yield 1; yield 2; yield 3; }
Generators are similar to iterators that calculate their values on demand, thus potentially using fewer resources. They can be created using the yield
keyword, e.g.:
function my_generator() { yield 1; yield 2; yield 3; }