CheckString checks whether the function argument at index is a string and returns this string. This function uses ToString to get its result, so all conversions and caveats of that function apply here.
(l *State, index int)
| 315 | // |
| 316 | // This function uses ToString to get its result, so all conversions and caveats of that function apply here. |
| 317 | func CheckString(l *State, index int) string { |
| 318 | if s, ok := l.ToString(index); ok { |
| 319 | return s |
| 320 | } |
| 321 | tagError(l, index, TypeString) |
| 322 | panic("unreachable") |
| 323 | } |
| 324 | |
| 325 | // OptString returns the string at index if it is a string. If this argument is |
| 326 | // absent or is nil, returns def. Otherwise, raises an error. |