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

Method OptInt

auxlib.go:144–154  ·  view source on GitHub ↗

* }}} */ * optType {{{ */

(n int, d int)

Source from the content-addressed store, hash-verified

142/* optType {{{ */
143
144func (ls *LState) OptInt(n int, d int) int {
145 v := ls.Get(n)
146 if v == LNil {
147 return d
148 }
149 if intv, ok := v.(LNumber); ok {
150 return int(intv)
151 }
152 ls.TypeError(n, LTNumber)
153 return 0
154}
155
156func (ls *LState) OptInt64(n int, d int64) int64 {
157 v := ls.Get(n)

Callers 14

osExitFunction · 0.80
baseErrorFunction · 0.80
baseToNumberFunction · 0.80
baseUnpackFunction · 0.80
TestOptIntFunction · 0.80
fileSetVBufFunction · 0.80
strByteFunction · 0.80
strFindFunction · 0.80
strGsubFunction · 0.80
strMatchFunction · 0.80
strSubFunction · 0.80
debugTracebackFunction · 0.80

Calls 2

GetMethod · 0.95
TypeErrorMethod · 0.95

Tested by 1

TestOptIntFunction · 0.64