note 129826 added to generator.current
| From: | ctx2002@gmail.com | Date: | Tue, 29 Oct 2024 06:31:21 +0000 |
| Subject: | note 129826 added to generator.current | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221619@lists.php.net to get a copy of this message | ||
I think what "gib-o-master" said is wrong.
Generator::current method does not advances "untouched generator".
let me give an example:
function y1()
{
yield 1;
}
$g = y1();
if ($g->valid()) { //at this point, PHP outputs "valid"
echo "valid\n";
}
echo "current v:" . $g->current() . "\n"; //at this point, PHP outputs
current v:1
if ($g->valid()) { //at this point, PHP still outputs "valid"
echo "valid\n";
} else {
echo "not valid\n";
}
if Generator::current method advances generator, then above If statement should outputs "not
valid"
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 125.237.150.77)
----
Manual Page -- https://php.net/manual/en/generator.current.php
Edit -- https://main.php.net/note/edit/129826
Del: integrated -- https://main.php.net/note/delete/129826/integrated
Del: useless -- https://main.php.net/note/delete/129826/useless
Del: bad code -- https://main.php.net/note/delete/129826/bad+code
Del: spam -- https://main.php.net/note/delete/129826/spam
Del: non-english -- https://main.php.net/note/delete/129826/non-english
Del: in docs -- https://main.php.net/note/delete/129826/in+docs
Del: other reasons-- https://main.php.net/note/delete/129826
Reject -- https://main.php.net/note/reject/129826
Search -- https://main.php.net/manage/user-notes.php