MCPcopy Index your code
hub / github.com/yuin/gopher-lua / ToInt

Method ToInt

state.go:1660–1670  ·  view source on GitHub ↗
(n int)

Source from the content-addressed store, hash-verified

1658}
1659
1660func (ls *LState) ToInt(n int) int {
1661 if lv, ok := ls.Get(n).(LNumber); ok {
1662 return int(lv)
1663 }
1664 if lv, ok := ls.Get(n).(LString); ok {
1665 if num, err := parseNumber(string(lv)); err == nil {
1666 return int(num)
1667 }
1668 }
1669 return 0
1670}
1671
1672func (ls *LState) ToInt64(n int) int64 {
1673 if lv, ok := ls.Get(n).(LNumber); ok {

Callers 1

TestToIntFunction · 0.45

Calls 2

GetMethod · 0.95
parseNumberFunction · 0.85

Tested by 1

TestToIntFunction · 0.36