rfc:generator-return-expressions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:generator-return-expressions [2015/03/09 15:49] – rewording rdlowrey | rfc:generator-return-expressions [2015/03/09 16:23] – formatting rdlowrey | ||
---|---|---|---|
Line 2: | Line 2: | ||
* Version: 0.1 | * Version: 0.1 | ||
* Date: 2015-02-18 | * Date: 2015-02-18 | ||
- | * Authors: Daniel Lowrey < | + | * Author: Daniel Lowrey < |
* Contributors: | * Contributors: | ||
* Status: Under Discussion | * Status: Under Discussion | ||
Line 170: | Line 170: | ||
return $bar + 42; // unambiguous execution " | return $bar + 42; // unambiguous execution " | ||
}; | }; | ||
+ | ?> | ||
</ | </ | ||
+ | |||
+ | |||
+ | ===== Reference Returns ===== | ||
+ | |||
+ | Generators currently utilize the `&` operator to indicate values will be yielded by-reference: | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | function & | ||
+ | $value = 3; | ||
+ | |||
+ | while ($value > 0) { | ||
+ | yield $value; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | foreach (gen_reference() as & | ||
+ | echo (--$number).' | ||
+ | } | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | As '' | ||
rfc/generator-return-expressions.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1