Garry's Mod Wiki

Revision Difference

coroutine.yield#514149

<function name="yield" parent="coroutine" type="libraryfunc">⤶ <description>Pauses the active coroutine and passes all additional variables to the call of <page>coroutine.resume</page> that resumed the coroutine last time, and returns all additional variables that were passed to the previous call of resume.</description>⤶ <realm>Shared and Menu</realm>⤶ <args>⤶ <arg name="returnValue" type="vararg">Arguments to be returned by the last call of &lt;page&gt;coroutine.resume&lt;/page&gt;</arg>⤶ </args>⤶ <rets>⤶ <ret name="" type="vararg">Arguments that were set previously by <page>coroutine.resume</page></ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>Demonstrates the use of using varargs as a return value.</description>⤶ <code>⤶ local co = coroutine.create( function()⤶ coroutine.yield( "Hello world!" )⤶ end )⤶ print( coroutine.resume( co ) )⤶ </code>⤶ <output>true, "Hello world!"</output>⤶ ⤶ </example>