Garry's Mod Wiki

coroutine.yield

  vararg coroutine.yield( ... )

Description

Pauses the active coroutine and passes all additional variables to the call of coroutine.resume that resumed the coroutine last time, and returns all additional variables that were passed to the previous call of resume.

Arguments

1 vararg returnValue
Arguments to be returned by the last call of coroutine.resume.

Returns

1 vararg
Arguments that were set previously by coroutine.resume.

Example

Demonstrates the use of using varargs as a return value.

local co = coroutine.create( function() coroutine.yield( "Hello world!" ) end ) print( coroutine.resume( co ) )
Output:
true, "Hello world!"