github.com/hirochachacha/plua@v0.0.0-20170217012138-c82f520cc725/stdlib/table/len.go (about)

     1  package table
     2  
     3  import (
     4  	"github.com/hirochachacha/plua/internal/arith"
     5  	"github.com/hirochachacha/plua/object"
     6  )
     7  
     8  func callLen(th object.Thread, t object.Value) (int, *object.RuntimeError) {
     9  	l, err := arith.CallLen(th, t)
    10  	if err != nil {
    11  		return 0, err
    12  	}
    13  	tlen, ok := object.ToGoInt(l)
    14  	if !ok {
    15  		return 0, object.NewRuntimeError("object length is not an integer")
    16  	}
    17  	return tlen, nil
    18  }