Checks whether the given index is an LChannel and returns this channel.
(n int)
| 439 | |
| 440 | // Checks whether the given index is an LChannel and returns this channel. |
| 441 | func (ls *LState) CheckChannel(n int) chan LValue { |
| 442 | v := ls.Get(n) |
| 443 | if ch, ok := v.(LChannel); ok { |
| 444 | return (chan LValue)(ch) |
| 445 | } |
| 446 | ls.TypeError(n, LTChannel) |
| 447 | return nil |
| 448 | } |
| 449 | |
| 450 | // If the given index is a LChannel, returns this channel. If this argument is absent or is nil, returns ch. Otherwise, raises an error. |
| 451 | func (ls *LState) OptChannel(n int, ch chan LValue) chan LValue { |