Channel:peek

Returns a message from the Channel without popping it from the queue. If the Channel is empty, nil is returned. This can be useful to determine if the Channel is empty.

message, present = Channel:peek()

Arguments

None

Returns

NameTypeDescription
message*The message, or nil if there is no message.
presentbooleanWhether a message was returned (use to detect nil).

Notes

The second return value can be used to detect if a nil message is in the queue.

See also