cc.expect

The cc.expect library provides helper functions for verifying that function arguments are well-formed and of the correct type.

Usage

expect(index, value, ...)Expect an argument to have a specific type.
field(tbl, index, ...)Expect an field to have a specific type.
expect(index, value, ...)Source

Expect an argument to have a specific type.

Parameters

  1. index number The 1-based argument index.
  2. value The argument's value.
  3. ... string The allowed types of the argument.

Returns

  1. The given value.

Throws

  • If the value is not one of the allowed types.

field(tbl, index, ...)Source

Expect an field to have a specific type.

Parameters

  1. tbl table The table to index.
  2. index string The field name to check.
  3. ... string The allowed types of the argument.

Returns

  1. The contents of the given field.

Throws

  • If the field is not one of the allowed types.