GoLang Generator::getReturn

request it (128)
GoLang replacement for PHP's Generator::getReturn [edit | history]



Do you know a GoLang replacement for PHP's Generator::getReturn? Write it!

PHP Generator::getReturn

PHP original manual for Generator::getReturn [ show | php.net ]

Generator::getReturn

(PHP 7)

Generator::getReturnGet the return value of a generator

Description

public mixed Generator::getReturn ( void )

Parameters

This function has no parameters.

Return Values

Returns the generator's return value once it has finished executing.

Examples

Example #1 Generator::getReturn() example

<?php

$gen 
= (function() {
    
yield 1;
    
yield 2;

    return 
3;
})();

foreach (
$gen as $val) {
    echo 
$valPHP_EOL;
}

echo 
$gen->getReturn(), PHP_EOL;

The above example will output:

1
2
3